diff --git a/protocols/sub/pubnub.go b/protocols/sub/pubnub.go index 9ddca5b..d85c8f1 100644 --- a/protocols/sub/pubnub.go +++ b/protocols/sub/pubnub.go @@ -1,6 +1,7 @@ package sub import ( + "errors" "fmt" "os" @@ -82,11 +83,22 @@ func (sub *PubnubSubscriber) Configure(config map[string]interface{}) error { if err != nil { return err } + err = validatePubnubConfig(sub.pubnubConfig) + if err != nil { + return err + } sub.pubnubConfig.FileName = strings.Replace(sub.pubnubConfig.Topic, "/", "", -1) return err } +func validatePubnubConfig(cfg pubnubConfig) error { + if cfg.SubscribeKey == "" { + return errors.New("Subscribe Key Missing") + } + return nil +} + func (sub *PubnubSubscriber) Close() { sub.connection.Destroy(sub.pubnubConfig.Topic) }