@@ -62,11 +62,19 @@ class Dispatcher:
62
62
async def run():
63
63
host = os.getenv("DISPATCH_API_HOST", "localhost")
64
64
port = os.getenv("DISPATCH_API_PORT", "50051")
65
+ key = os.getenv("DISPATCH_API_KEY", "some-key")
65
66
66
67
service_address = f"{host}:{port}"
67
- grpc_channel = grpc.aio.insecure_channel(service_address)
68
- microgrid_id = 1
69
- dispatcher = Dispatcher(microgrid_id, grpc_channel, service_address)
68
+ grpc_channel = grpc.aio.secure_channel(
69
+ service_address,
70
+ credentials=grpc.ssl_channel_credentials()
71
+ )
72
+ dispatcher = Dispatcher(
73
+ microgrid_id=1,
74
+ grpc_channel=grpc_channel,
75
+ svc_addr=service_address,
76
+ key=key
77
+ )
70
78
await dispatcher.start()
71
79
72
80
actor = MagicMock() # replace with your actor
@@ -110,12 +118,20 @@ async def run():
110
118
async def run():
111
119
host = os.getenv("DISPATCH_API_HOST", "localhost")
112
120
port = os.getenv("DISPATCH_API_PORT", "50051")
121
+ key = os.getenv("DISPATCH_API_KEY", "some-key")
113
122
114
123
service_address = f"{host}:{port}"
115
- grpc_channel = grpc.aio.insecure_channel(service_address)
116
- microgrid_id = 1
117
- dispatcher = Dispatcher(microgrid_id, grpc_channel, service_address)
118
- dispatcher.start() # this will start the actor
124
+ grpc_channel = grpc.aio.secure_channel(
125
+ service_address,
126
+ credentials=grpc.ssl_channel_credentials()
127
+ )
128
+ dispatcher = Dispatcher(
129
+ microgrid_id=1,
130
+ grpc_channel=grpc_channel,
131
+ svc_addr=service_address,
132
+ key=key
133
+ )
134
+ await dispatcher.start() # this will start the actor
119
135
120
136
events_receiver = dispatcher.lifecycle_events.new_receiver()
121
137
@@ -146,11 +162,21 @@ async def run():
146
162
async def run():
147
163
host = os.getenv("DISPATCH_API_HOST", "localhost")
148
164
port = os.getenv("DISPATCH_API_PORT", "50051")
165
+ key = os.getenv("DISPATCH_API_KEY", "some-key")
149
166
150
- service_address = f"{host}:{port}"
151
- grpc_channel = grpc.aio.insecure_channel(service_address)
152
167
microgrid_id = 1
153
- dispatcher = Dispatcher(microgrid_id, grpc_channel, service_address)
168
+
169
+ service_address = f"{host}:{port}"
170
+ grpc_channel = grpc.aio.secure_channel(
171
+ service_address,
172
+ credentials=grpc.ssl_channel_credentials()
173
+ )
174
+ dispatcher = Dispatcher(
175
+ microgrid_id=microgrid_id,
176
+ grpc_channel=grpc_channel,
177
+ svc_addr=service_address,
178
+ key=key
179
+ )
154
180
await dispatcher.start() # this will start the actor
155
181
156
182
# Create a new dispatch
0 commit comments