Skip to content

Commit 3beff13

Browse files
committed
feat: controller northbound API - set route
Signed-off-by: Laszlo Puskas <laszlo.puskas1@gmail.com>
1 parent 8abc1da commit 3beff13

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

docs/messaging/slim-group.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,53 @@ Example golang code fragments:
161161

162162
### Set routes for the group name between slim nodes
163163

164-
TBD
164+
```go
165+
conn, err := grpc.NewClient("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
166+
client := controlplaneApi.NewControlPlaneServiceClient(conn) // Replace nil with actual gRPC client connection
167+
168+
if err != nil {
169+
log.Fatalf("did not connect: %v", err)
170+
}
171+
defer conn.Close()
172+
173+
createConnectionResponse, err := client.CreateConnection(context.Background(),
174+
&controlplaneApi.CreateConnectionRequest{
175+
Connection: &grpcapi.Connection{
176+
ConnectionId: "http://127.0.0.1:46357",
177+
ConfigData: "{\"endpoint\": \"http://127.0.0.1:46357\"}",
178+
},
179+
NodeId: "slim/0",
180+
})
181+
if err != nil {
182+
log.Fatalf("failed to create connection: %w", err)
183+
}
184+
185+
connectionID := createConnectionResponse.ConnectionId
186+
if !createConnectionResponse.Success {
187+
log.Fatal("failed to create connection")
188+
}
189+
fmt.Printf("Connection created successfully with ID: %v\n", connectionID)
190+
191+
subscription := &grpcapi.Subscription{
192+
Component_0: "organization",
193+
Component_1: "namespace",
194+
Component_2: "appName",
195+
ConnectionId: connectionID,
196+
}
197+
198+
createSubscriptionResponse, err := client.CreateSubscription(context.Background(), &controlplaneApi.CreateSubscriptionRequest{
199+
NodeId: "slim/0",
200+
Subscription: subscription,
201+
})
202+
if err != nil {
203+
log.Fatalf("failed to create subscription: %w", err)
204+
}
205+
if !createSubscriptionResponse.Success {
206+
log.Fatalf("failed to create subscription")
207+
}
208+
fmt.Printf("Subscrption created successfully with ID: %v\n", createSubscriptionResponse.SubscriptionId)
209+
210+
```
165211

166212
## Identity management
167213

0 commit comments

Comments
 (0)