Skip to content

Commit

Permalink
Don't rely on subscription configuration to get subscription name
Browse files Browse the repository at this point in the history
When using the API directly, there is not subscription configuration (it
is set in the app module) and we cannot use it to get the name. Instead,
use the name provided in the function call.

This is a regression introduced in #331.
  • Loading branch information
vincentbernat committed Jan 13, 2024
1 parent d531213 commit d7dea23
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 d7dea23

Please sign in to comment.