Read list type of environment variables
[ric-plt/sdlgo.git] / example / example.go
index aee1c19..33a9194 100644 (file)
@@ -26,6 +26,7 @@ import (
        "fmt"
 
        "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
+       "time"
 )
 
 var sdl *sdlgo.SyncStorage
@@ -59,8 +60,28 @@ func exampleClose() {
        sdl.Close()
 }
 
+func sdlNotify(ch string, events ...string) {
+       fmt.Printf("CB1 channel=%+v, events=%+v\n", ch, events[0])
+}
+
+func sdlNotify2(ch string, events ...string) {
+       fmt.Printf("CB2 channel=%+v, events=%+v\n", ch, events[0])
+}
+
 func main() {
-       exampleSet()
-       exampleGet()
-       exampleClose()
+       sdl.SubscribeChannel("dcapterm_subsRTPM-localhost:55566", sdlNotify, "my-ch")
+       sdl.SubscribeChannel("dcapterm_subsRTPM-localhost:55565", sdlNotify2, "my-ch")
+       time.Sleep(3 * time.Second)
+       sdl.SetAndPublish("dcapterm_subsRTPM-localhost:55566", []string{"my-ch", "my-event1"}, "my-key", "my-data")
+       sdl.SetAndPublish("dcapterm_subsRTPM-localhost:55565", []string{"my-ch", "my-event2"}, "my-key", "my-data")
+
+       time.Sleep(2 * time.Second)
+       //sdl.UnsubscribeChannel("dcapterm_subsRTPM-localhost:55565", "my-ch")
+       //time.Sleep(2 * time.Second)
+       //sdl.SetAndPublish("dcapterm_subsRTPM-localhost:55565", []string{"my-ch", "my-event2"}, "my-key", "my-data")
+       time.Sleep(2 * time.Second)
+
+       //exampleSet()
+       //exampleGet()
+       //exampleClose()
 }