github.com/glide-im/glide@v1.6.0/pkg/subscription/interface.go (about) 1 package subscription 2 3 import ( 4 "errors" 5 "github.com/glide-im/glide/pkg/gate" 6 ) 7 8 const ( 9 SubscriberSubscribe int64 = 1 10 SubscriberUnsubscribe = 2 11 SubscriberUpdate = 5 12 ) 13 14 const ( 15 ChanCreate int64 = 1 16 ChanDelete = 2 17 ChanUpdate = 3 18 ) 19 20 var ( 21 ErrUnknownFlag = errors.New("unknown flag") 22 ) 23 24 // ChanID is a unique identifier for a channel. 25 type ChanID string 26 27 type SubscriberID string 28 29 type Update struct { 30 Flag int64 31 ID SubscriberID 32 33 Extra interface{} 34 } 35 36 type ChannelUpdate struct { 37 Flag int64 38 39 Extra interface{} 40 } 41 42 type Interface interface { 43 PublishMessage(id ChanID, message Message) error 44 } 45 46 type Subscribe interface { 47 Interface 48 49 SetGateInterface(gate gate.DefaultGateway) 50 51 UpdateSubscriber(id ChanID, updates []Update) error 52 53 UpdateChannel(id ChanID, update ChannelUpdate) error 54 } 55 56 type Server interface { 57 Subscribe 58 59 Run() error 60 }