Skip to content

Commit

Permalink
Merge pull request #352 from vincentbernat/fix/subscription-name
Browse files Browse the repository at this point in the history
Don't rely on subscription configuration to get subscription name
  • Loading branch information
karimra authored Jan 18, 2024
2 parents 741439e + d7dea23 commit 7561948
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/target/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ SUBSC:

switch req.GetSubscribe().GetMode() {
case gnmi.SubscriptionList_STREAM:
err = t.handleStreamSubscriptionRcv(nctx, subscribeClient, subConfig)
err = t.handleStreamSubscriptionRcv(nctx, subscribeClient, subscriptionName, subConfig)
if err != nil {
t.errors <- &TargetError{
SubscriptionName: subscriptionName,
Expand All @@ -83,7 +83,7 @@ SUBSC:
goto SUBSC
}
case gnmi.SubscriptionList_ONCE:
err = t.handleONCESubscriptionRcv(nctx, subscribeClient, subConfig)
err = t.handleONCESubscriptionRcv(nctx, subscribeClient, subscriptionName, subConfig)
if err != nil {
t.errors <- &TargetError{
SubscriptionName: subscriptionName,
Expand All @@ -103,7 +103,7 @@ SUBSC:
return
case gnmi.SubscriptionList_POLL:
go t.listenPolls(nctx)
err = t.handlePollSubscriptionRcv(nctx, subscribeClient, subConfig)
err = t.handlePollSubscriptionRcv(nctx, subscribeClient, subscriptionName, subConfig)
if err != nil {
t.errors <- &TargetError{
SubscriptionName: subscriptionName,
Expand Down Expand Up @@ -257,7 +257,7 @@ func (t *Target) listenPolls(ctx context.Context) {
}
}

func (t *Target) handleStreamSubscriptionRcv(ctx context.Context, stream gnmi.GNMI_SubscribeClient, subConfig *types.SubscriptionConfig) error {
func (t *Target) handleStreamSubscriptionRcv(ctx context.Context, stream gnmi.GNMI_SubscribeClient, subscriptionName string, subConfig *types.SubscriptionConfig) error {
for {
if ctx.Err() != nil {
return nil
Expand All @@ -267,14 +267,14 @@ func (t *Target) handleStreamSubscriptionRcv(ctx context.Context, stream gnmi.GN
return err
}
t.subscribeResponses <- &SubscribeResponse{
SubscriptionName: subConfig.Name,
SubscriptionName: subscriptionName,
SubscriptionConfig: subConfig,
Response: response,
}
}
}

func (t *Target) handleONCESubscriptionRcv(ctx context.Context, stream gnmi.GNMI_SubscribeClient, subConfig *types.SubscriptionConfig) error {
func (t *Target) handleONCESubscriptionRcv(ctx context.Context, stream gnmi.GNMI_SubscribeClient, subscriptionName string, subConfig *types.SubscriptionConfig) error {
for {
if ctx.Err() != nil {
return nil
Expand All @@ -284,7 +284,7 @@ func (t *Target) handleONCESubscriptionRcv(ctx context.Context, stream gnmi.GNMI
return err
}
t.subscribeResponses <- &SubscribeResponse{
SubscriptionName: subConfig.Name,
SubscriptionName: subscriptionName,
SubscriptionConfig: subConfig,
Response: response,
}
Expand All @@ -295,7 +295,7 @@ func (t *Target) handleONCESubscriptionRcv(ctx context.Context, stream gnmi.GNMI
}
}

func (t *Target) handlePollSubscriptionRcv(ctx context.Context, stream gnmi.GNMI_SubscribeClient, subConfig *types.SubscriptionConfig) error {
func (t *Target) handlePollSubscriptionRcv(ctx context.Context, stream gnmi.GNMI_SubscribeClient, subscriptionName string, subConfig *types.SubscriptionConfig) error {
for {
select {
case <-ctx.Done():
Expand All @@ -306,7 +306,7 @@ func (t *Target) handlePollSubscriptionRcv(ctx context.Context, stream gnmi.GNMI
return err
}
t.subscribeResponses <- &SubscribeResponse{
SubscriptionName: subConfig.Name,
SubscriptionName: subscriptionName,
SubscriptionConfig: subConfig,
Response: response,
}
Expand Down

0 comments on commit 7561948

Please sign in to comment.