Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
614c625f
Commit
614c625f
authored
7 months ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Pre-merge code cleanup
parent
c43486a2
Branches
feat/tid-pcep
Branches containing commit
No related tags found
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!259
Resolve "(CTTC) Replace DLT Gateway functionality with an opensource and Hyper Ledger v2.4+ compliant version"
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dlt/connector/client/DltGatewayClient.py
+32
-1
32 additions, 1 deletion
src/dlt/connector/client/DltGatewayClient.py
src/dlt/connector/client/DltGatewayClientAsync.py
+4
-5
4 additions, 5 deletions
src/dlt/connector/client/DltGatewayClientAsync.py
with
36 additions
and
6 deletions
src/dlt/connector/client/DltGatewayClient.py
+
32
−
1
View file @
614c625f
...
...
@@ -15,7 +15,10 @@
import
grpc
,
logging
from
typing
import
Iterator
from
common.proto.dlt_gateway_pb2
import
DltRecordEvent
,
DltRecordSubscription
from
common.proto.context_pb2
import
Empty
,
TeraFlowController
from
common.proto.dlt_gateway_pb2
import
(
DltPeerStatus
,
DltPeerStatusList
,
DltRecord
,
DltRecordEvent
,
DltRecordId
,
DltRecordStatus
,
DltRecordSubscription
)
from
common.proto.dlt_gateway_pb2_grpc
import
DltGatewayServiceStub
from
common.tools.client.RetryDecorator
import
retry
,
delay_exponential
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
...
...
@@ -47,9 +50,37 @@ class DltGatewayClient:
self
.
channel
=
None
self
.
stub
=
None
@RETRY_DECORATOR
def
RecordToDlt
(
self
,
request
:
DltRecord
)
->
DltRecordStatus
:
LOGGER
.
debug
(
'
RecordToDlt request: {:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
response
=
self
.
stub
.
RecordToDlt
(
request
)
LOGGER
.
debug
(
'
RecordToDlt result: {:s}
'
.
format
(
grpc_message_to_json_string
(
response
)))
return
response
@RETRY_DECORATOR
def
GetFromDlt
(
self
,
request
:
DltRecordId
)
->
DltRecord
:
LOGGER
.
debug
(
'
GetFromDlt request: {:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
response
=
self
.
stub
.
GetFromDlt
(
request
)
LOGGER
.
debug
(
'
GetFromDlt result: {:s}
'
.
format
(
grpc_message_to_json_string
(
response
)))
return
response
@RETRY_DECORATOR
def
SubscribeToDlt
(
self
,
request
:
DltRecordSubscription
)
->
Iterator
[
DltRecordEvent
]:
LOGGER
.
debug
(
'
SubscribeToDlt request: {:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
response
=
self
.
stub
.
SubscribeToDlt
(
request
)
LOGGER
.
debug
(
'
SubscribeToDlt result: {:s}
'
.
format
(
grpc_message_to_json_string
(
response
)))
return
response
@RETRY_DECORATOR
def
GetDltStatus
(
self
,
request
:
TeraFlowController
)
->
DltPeerStatus
:
LOGGER
.
debug
(
'
GetDltStatus request: {:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
response
=
self
.
stub
.
GetDltStatus
(
request
)
LOGGER
.
debug
(
'
GetDltStatus result: {:s}
'
.
format
(
grpc_message_to_json_string
(
response
)))
return
response
@RETRY_DECORATOR
def
GetDltPeers
(
self
,
request
:
Empty
)
->
DltPeerStatusList
:
LOGGER
.
debug
(
'
GetDltPeers request: {:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
response
=
self
.
stub
.
GetDltPeers
(
request
)
LOGGER
.
debug
(
'
GetDltPeers result: {:s}
'
.
format
(
grpc_message_to_json_string
(
response
)))
return
response
This diff is collapsed.
Click to expand it.
src/dlt/connector/client/DltGatewayClientAsync.py
+
4
−
5
View file @
614c625f
...
...
@@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
grpc
,
logging
,
asyncio
import
asyncio
,
grpc
,
logging
from
typing
import
Iterator
,
List
from
common.proto.context_pb2
import
Empty
,
TeraFlowController
from
common.proto.dlt_gateway_pb2
import
(
DltPeerStatus
,
DltPeerStatusList
,
DltRecord
,
DltRecordEvent
,
DltRecordId
,
DltRecordStatus
,
DltRecordSubscription
)
DltPeerStatus
,
DltPeerStatusList
,
DltRecord
,
DltRecordEvent
,
DltRecordId
,
DltRecordStatus
,
DltRecordSubscription
)
from
common.proto.dlt_gateway_pb2_grpc
import
DltGatewayServiceStub
from
common.tools.client.RetryDecorator
import
retry
,
delay_exponential
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
...
...
@@ -35,9 +36,7 @@ class DltGatewayClientAsync:
LOGGER
.
debug
(
'
Creating channel to {:s}...
'
.
format
(
self
.
endpoint
))
self
.
channel
=
None
self
.
stub
=
None
#self.connect()
self
.
message_queue
:
List
[
DltRecord
]
=
[]
#LOGGER.debug('Channel created')
async
def
connect
(
self
):
self
.
channel
=
grpc
.
aio
.
insecure_channel
(
self
.
endpoint
)
...
...
@@ -56,7 +55,7 @@ class DltGatewayClientAsync:
response
=
await
self
.
stub
.
RecordToDlt
(
request
)
LOGGER
.
debug
(
'
RecordToDlt result: {:s}
'
.
format
(
grpc_message_to_json_string
(
response
)))
return
response
@RETRY_DECORATOR
async
def
GetFromDlt
(
self
,
request
:
DltRecordId
)
->
DltRecord
:
LOGGER
.
debug
(
'
GetFromDlt request: {:s}
'
.
format
(
grpc_message_to_json_string
(
request
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment