-
Notifications
You must be signed in to change notification settings - Fork 259
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
base: main
Are you sure you want to change the base?
Conversation
subscription.go
Outdated
} | ||
|
||
// update subscription parameters | ||
s.params = ¶ms |
There was a problem hiding this comment.
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):
Line 353 in 5aed8b4
func (s *Subscription) recreate_NeedsSubMuxLock(ctx context.Context) error { |
There was a problem hiding this comment.
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:
s.params = ¶ms | |
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: ¶ms, | |
nextSeq: s.nextSeq, | |
c: s.c, | |
} | |
s.itemsMu.Unlock() | |
err = sub.recreate_NeedsSubMuxLock(ctx) | |
if err != nil { | |
return nil, err | |
} |
85acce4
to
47e6bf5
Compare
closes gopcua#713 Signed-off-by: Jack Chen <[email protected]>
closes #713
Simply add the following code to
examples/subscribe/subscribe.go
can test this new feature