Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
eaa08e45
Commit
eaa08e45
authored
Aug 19, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rest Gateway / Trace Retrieval: fixed communication
parent
140ea8d9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
12 deletions
+23
-12
swagger.yml
rest-gateway/app/configs/swagger.yml
+4
-0
main.py
rest-gateway/app/main.py
+0
-4
blockchain_trace.py
rest-gateway/app/rest/blockchain_trace.py
+12
-5
MongoRepository.py
...in/trace-retrieval-microservice/app/db/MongoRepository.py
+2
-0
MessageHandler.py
...ce-retrieval-microservice/app/messaging/MessageHandler.py
+5
-3
No files found.
rest-gateway/app/configs/swagger.yml
View file @
eaa08e45
...
...
@@ -76,9 +76,13 @@ definitions:
TransactionFrom
:
type
:
"
string"
format
:
"
uuid"
TransactionFromLatLng
:
type
:
"
string"
TransactionTo
:
type
:
"
string"
format
:
"
uuid"
TransactionToLatLng
:
type
:
"
string"
TransferredAsset
:
type
:
"
string"
ResourceIds
:
...
...
rest-gateway/app/main.py
View file @
eaa08e45
...
...
@@ -21,10 +21,6 @@ from MessageList import MessageList
messages
=
MessageList
.
getInstance
()
message_sender
=
MessageSender
()
message_sender
.
connect
()
message_sender
.
create_exchange
(
'inhub'
,
'direct'
)
# init message handler
def
message_received_callback
(
channel
,
method
,
properties
,
body
):
messages
.
appendMessage
(
body
)
...
...
rest-gateway/app/rest/blockchain_trace.py
View file @
eaa08e45
from
flask
import
request
,
Response
import
main
from
messaging.MessageSender
import
MessageSender
import
json
# import main
message_sender
=
MessageSender
()
message_sender
.
connect
()
message_sender
.
create_exchange
(
'inhub'
,
'direct'
)
def
receive
():
body
=
request
.
json
if
isBlockchainTraceValid
(
body
):
message
=
{
'type'
:
'blockchain-transaction'
,
'content'
:
body
}
main
.
message_sender
.
send
(
'inhub'
,
message
,
'trace-retrieval'
)
return
Response
(
status
=
201
)
message
=
{
'type'
:
'blockchain-transaction'
,
'content'
:
json
.
dumps
(
body
)}
message_sender
.
send
(
'inhub'
,
json
.
dumps
(
message
),
'trace-retrieval'
)
return
Response
(
status
=
201
)
return
Response
(
status
=
400
)
def
isBlockchainTraceValid
(
trace
)
->
bool
:
return
'TransactionId'
in
trace
\
...
...
transaction-hub-in/trace-retrieval-microservice/app/db/MongoRepository.py
View file @
eaa08e45
import
pymongo
MONGO_DB_HOST
=
'trace-retrieval-db'
# MONGO_DB_HOST = '143.205.173.36'
MONGO_DB_PORT
=
'27017'
# MONGO_DB_PORT = '30003'
class
MongoRepository
:
# TODO extract to docker env var
...
...
transaction-hub-in/trace-retrieval-microservice/app/messaging/MessageHandler.py
View file @
eaa08e45
from
db.MongoRepository
import
MongoRepository
import
json
import
logging
LOGGER
=
logging
.
getLogger
(
__name__
)
...
...
@@ -11,12 +12,13 @@ class MessageHandler:
def
handle_message
(
self
,
body
):
LOGGER
.
info
(
f
"Received message: {body}"
)
if
not
'type'
in
body
:
message
=
json
.
loads
(
body
)
if
not
'type'
in
message
:
LOGGER
.
warning
(
f
"Message has no type field"
)
return
if
body
[
'type'
]
==
'blockchain-transaction'
:
self
.
handle_blockchain_transaction
(
body
[
'content'
]
)
if
message
[
'type'
]
==
'blockchain-transaction'
:
self
.
handle_blockchain_transaction
(
json
.
loads
(
message
[
'content'
])
)
def
handle_blockchain_transaction
(
self
,
transaction
):
self
.
_mongo_repo
.
insert_trace
(
transaction
)
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