Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
task9_redis_receiver
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
arun.uday
task9_redis_receiver
Commits
c5dd2c9a
Commit
c5dd2c9a
authored
Feb 06, 2023
by
arun.uday
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v4
parent
2912f84a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
13 deletions
+55
-13
.idea/sonarlint/issuestore/index.pb
+4
-0
.idea/workspace.xml
+32
-6
conf/application.conf
+1
-0
scripts/config/applications_config.py
+1
-0
scripts/core/database/redis_db.py
+2
-2
scripts/core/handlers/add_patient_queue.py
+5
-0
scripts/services/receiver_app_run.py
+10
-5
No files found.
.idea/sonarlint/issuestore/index.pb
View file @
c5dd2c9a
No preview for this file type
.idea/workspace.xml
View file @
c5dd2c9a
...
...
@@ -4,9 +4,15 @@
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"530f9a40-4e97-41f4-9693-adc3b4faba7d"
name=
"Changes"
comment=
"v2"
>
<list
default=
"true"
id=
"530f9a40-4e97-41f4-9693-adc3b4faba7d"
name=
"Changes"
comment=
"v3"
>
<change
afterPath=
"$PROJECT_DIR$/scripts/core/database/redis_db.py"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/scripts/core/handlers/add_patient_queue.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/sonarlint/issuestore/index.pb"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/sonarlint/issuestore/index.pb"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/scripts/config/api_route_config.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/scripts/config/api_route_config.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/conf/application.conf"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/conf/application.conf"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/scripts/config/applications_config.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/scripts/config/applications_config.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/scripts/core/engine/redis_db.py"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/scripts/services/receiver_app_run.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/scripts/services/receiver_app_run.py"
afterDir=
"false"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
...
@@ -37,8 +43,8 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SONARLINT_PRECOMMIT_ANALYSIS": "true",
"last_opened_file_path": "E:/KL projects/task
10mqttreceiver2
",
"settings.editor.selected.configurable": "pr
oject.propVCSSupport.DirectoryMappings
"
"last_opened_file_path": "E:/KL projects/task
9receiverredis
",
"settings.editor.selected.configurable": "pr
eferences.pluginManager
"
}
}]]>
</component>
<component
name=
"RunManager"
>
...
...
@@ -88,12 +94,31 @@
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1675312818891
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"3"
/>
<task
id=
"LOCAL-00003"
summary=
"v3"
>
<created>
1675318625371
</created>
<option
name=
"number"
value=
"00003"
/>
<option
name=
"presentableId"
value=
"LOCAL-00003"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1675318625371
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"4"
/>
<servers
/>
</component>
<component
name=
"VcsManagerConfiguration"
>
<MESSAGE
value=
"v1"
/>
<MESSAGE
value=
"v2"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"v2"
/>
<MESSAGE
value=
"v3"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"v3"
/>
</component>
<component
name=
"XDebuggerManager"
>
<breakpoint-manager>
<breakpoints>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/scripts/services/receiver_app_run.py
</url>
<line>
9
</line>
<option
name=
"timeStamp"
value=
"1"
/>
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
conf/application.conf
View file @
c5dd2c9a
...
...
@@ -20,6 +20,7 @@ mongodb = mongodb://localhost:27017
[
redis_db
]
redis_host
=
127
.
0
.
0
.
1
db_queue_doctor
=
0
[
encode
]
encode
=
utf
-
8
...
...
scripts/config/applications_config.py
View file @
c5dd2c9a
...
...
@@ -27,6 +27,7 @@ uvicorn_app = config.get("uvicorn", "uvicorn_app")
# redis
redis_host
=
config
.
get
(
"redis_db"
,
"redis_host"
)
db_queue_doctor
=
config
.
get
(
"redis_db"
,
"db_queue_doctor"
)
# encode
utf_encode
=
config
.
get
(
"encode"
,
"encode"
)
scripts/core/
engin
e/redis_db.py
→
scripts/core/
databas
e/redis_db.py
View file @
c5dd2c9a
# connecting to the redis
import
redis
from
scripts.config.applications_config
import
redis_host
from
scripts.config.applications_config
import
redis_host
,
db_queue_doctor
conn
=
redis
.
Redis
(
redis_host
)
conn
=
redis
.
Redis
(
redis_host
,
db
=
db_queue_doctor
)
scripts/core/handlers/add_patient_queue.py
0 → 100644
View file @
c5dd2c9a
# patient to the queue
def
insert_data_redis
(
conn_queue
,
doctor
,
patient
):
# set the patient to the doctors queue
conn_queue
.
set
(
doctor
,
patient
)
print
(
doctor
,
" assigned to "
,
patient
)
scripts/services/receiver_app_run.py
View file @
c5dd2c9a
import
functools
import
paho.mqtt.client
as
mqtt
from
fastapi
import
FastAPI
from
scripts.config.api_route_config
import
index_route
from
scripts.config.applications_config
import
mqtt_host
,
port
,
request_no
,
utf_encode
from
scripts.core.engine.redis_db
import
conn
from
scripts.core.database.redis_db
import
conn
from
scripts.core.handlers.add_patient_queue
import
insert_data_redis
from
scripts.core.handlers.reading_doctors
import
read_doctors
# This is the Subscriber
...
...
@@ -21,15 +24,17 @@ def receiver():
read_doctors
(
conn
,
client_name
)
# printing the messages
def
on_message
(
client_name
,
userdata
,
msg
):
print
(
client_name
,
" "
,
userdata
)
def
on_message_handler
(
client_name
,
userdata
,
msg
):
# decoding the msg to string
print
(
client_name
,
" "
,
userdata
)
payload_decoded
=
msg
.
payload
.
decode
(
utf_encode
)
print
(
msg
.
topic
,
"assigned to"
,
payload_decoded
)
# add patient to the queue
insert_data_redis
(
conn
,
msg
.
topic
,
payload_decoded
)
# creating the paho client for mqtt
client
=
mqtt
.
Client
()
client
.
connect
(
mqtt_host
,
int
(
port
),
int
(
request_no
))
client
.
on_connect
=
on_connect
client
.
on_message
=
on_message
client
.
on_message
=
functools
.
partial
(
on_message_handler
)
client
.
loop_forever
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment