github.com/anycable/anycable-go@v1.5.1/streams/config.go (about) 1 // This package provides functionality to directly subscribe to streams 2 // without using channels (a simplified pub/sub mode) 3 package streams 4 5 type Config struct { 6 // Secret is a key used to sign and verify streams 7 Secret string 8 9 // Public determines if public (unsigned) streams are allowed 10 Public bool 11 12 // Whisper determines if whispering is enabled for pub/sub streams 13 Whisper bool 14 15 // PubSubChannel is the channel name used for direct pub/sub 16 PubSubChannel string 17 18 // Turbo is a flag to enable Turbo Streams support 19 Turbo bool 20 21 // TurboSecret is a custom secret key used to verify Turbo Streams 22 TurboSecret string 23 24 // CableReady is a flag to enable CableReady support 25 CableReady bool 26 27 // CableReadySecret is a custom secret key used to verify CableReady streams 28 CableReadySecret string 29 } 30 31 // NewConfig returns a new Config with the given key 32 func NewConfig() Config { 33 return Config{ 34 PubSubChannel: "$pubsub", 35 } 36 } 37 38 func (c Config) GetTurboSecret() string { 39 if c.TurboSecret != "" { 40 return c.TurboSecret 41 } 42 43 return c.Secret 44 } 45 46 func (c Config) GetCableReadySecret() string { 47 if c.CableReadySecret != "" { 48 return c.CableReadySecret 49 } 50 51 return c.Secret 52 }