Skip to content
Snippets Groups Projects
Commit d504ef53 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

added optional, configurable subscribe options

parent 8badc591
No related branches found
No related tags found
3 merge requests!376Add additional example application hostname-checker,!343Add basic application framework and example application to show interaction between events an NBI,!342Resolve "Add an option to send gNMI Subscribe requests via SBI"
Pipeline #108554 passed
This commit is part of merge request !342. Comments created here will be created in the context of that merge request.
...@@ -82,7 +82,7 @@ func initialize() error { ...@@ -82,7 +82,7 @@ func initialize() error {
c.deviceWatcher = nucleus.NewDeviceWatcher(c.pndStore) c.deviceWatcher = nucleus.NewDeviceWatcher(c.pndStore)
//TODO: Just an example for testing purposes, remove these calls after complete implementation of subscription handling! //TODO: Just an example for testing purposes, remove these calls after complete implementation of subscription handling!
c.deviceWatcher.SubToDevices([][]string{{"system", "config", "hostname"}}) c.deviceWatcher.SubToDevices([][]string{{"system", "config", "hostname"}}, nil)
go func() { go func() {
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
c.deviceWatcher.StopAndRemoveAllDeviceSubscriptions() c.deviceWatcher.StopAndRemoveAllDeviceSubscriptions()
......
...@@ -42,15 +42,17 @@ func NewDeviceWatcher(pndStore networkdomain.PndStore) *DeviceWatcher { ...@@ -42,15 +42,17 @@ func NewDeviceWatcher(pndStore networkdomain.PndStore) *DeviceWatcher {
} }
} }
// SubToDevices subscribes to every available device in each network domain with fixed gNMI subscription options (streaming in sample mode each second). // SubToDevices subscribes to every available device in each network domain according to provided SubscribeOptions.
// Paths should be provided in the following format [][]string{{"system", "config", "hostname"}} // Paths should be provided in the following format [][]string{{"system", "config", "hostname"}}
func (d *DeviceWatcher) SubToDevices(paths [][]string) { // SubscribeOptions can be nil. Use nil for a fixed, pre-defined set of gNMI subscription options (streaming in sample mode each second).
// TODO: think about passing opts as parameter for more configurability func (d *DeviceWatcher) SubToDevices(paths [][]string, opts *gnmi.SubscribeOptions) {
opts := &gnmi.SubscribeOptions{ if opts == nil {
Mode: gNMISubscribeMode, opts = &gnmi.SubscribeOptions{
StreamMode: gNMIStreamMode, Mode: gNMISubscribeMode,
Paths: paths, StreamMode: gNMIStreamMode,
SampleInterval: subscribeSampleInterval, Paths: paths,
SampleInterval: subscribeSampleInterval,
}
} }
pnds, err := d.pndStore.GetAll() pnds, err := d.pndStore.GetAll()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment