Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscription: add ModifySubscription functionality #714

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jackchenjc
Copy link
Contributor

closes #713

Simply add the following code to examples/subscribe/subscribe.go can test this new feature

var params opcua.SubscriptionParameters
params.Interval = time.Millisecond * 2000
_, err = sub.ModifySubscription(ctx, params)
if err != nil {
	log.Fatal(err)
}

subscription.go Outdated
}

// update subscription parameters
s.params = &params
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These might need a lock. But it doesn't look like we have one in Subscription. There's this func (with a truly awful name):

func (s *Subscription) recreate_NeedsSubMuxLock(ctx context.Context) error {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you suggest to create a new Subscription based on the current subscription and then invoke its recreate_NeedsSubMuxLock func to safely update these values?

Something like:

Suggested change
s.params = &params
s.itemsMu.Lock()
sub := &Subscription{
SubscriptionID: s.SubscriptionID,
RevisedPublishingInterval: time.Duration(res.RevisedPublishingInterval) * time.Millisecond,
RevisedLifetimeCount: res.RevisedLifetimeCount,
RevisedMaxKeepAliveCount: res.RevisedMaxKeepAliveCount,
Notifs: s.Notifs,
items: s.items,
params: &params,
nextSeq: s.nextSeq,
c: s.c,
}
s.itemsMu.Unlock()
err = sub.recreate_NeedsSubMuxLock(ctx)
if err != nil {
return nil, err
}

@jackchenjc jackchenjc force-pushed the issue-713 branch 2 times, most recently from 85acce4 to 47e6bf5 Compare May 9, 2024 06:55
closes gopcua#713

Signed-off-by: Jack Chen <jack@iotechsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subscription: add ModifySubscription functionality
2 participants