diff --git a/protocols/sub/pubnub.go b/protocols/sub/pubnub.go index 97cc665..e02ed48 100644 --- a/protocols/sub/pubnub.go +++ b/protocols/sub/pubnub.go @@ -1,6 +1,7 @@ package sub import ( + "errors" "fmt" "os" @@ -86,6 +87,10 @@ func (sub *PubnubSubscriber) Configure(configs []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) if len(configs) == 2 { redisConfig := configs[1].(map[string]interface{}) @@ -98,6 +103,13 @@ func (sub *PubnubSubscriber) Configure(configs []interface{}) error { 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) }