{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pubsub\n\n## Types\n\n```go\ntype Publisher struct {\n\t// contains filtered or unexported fields\n}\n```\nPublisher is basic pub/sub structure. Allows to send events and subscribe to them. Can be safely used from multiple goroutines.\n\n```go\nfunc NewPublisher(publishTimeout time.Duration, buffer int) *Publisher\n```\nNewPublisher creates a new pub/sub publisher to broadcast messages. The duration is used as the send timeout as to not block the publisher publishing messages to other clients if one client is slow or unresponsive. The buffer is used when creating new channels for subscribers.\n\n```go\nfunc (p *Publisher) Close()\n```\nClose closes the channels to all subscribers registered with the publisher.\n\n```go\nfunc (p *Publisher) Evict(sub chan interface{})\n```\nEvict removes the specified subscriber from receiving any more messages.\n\n```go\nfunc (p *Publisher) Len() int\n```\nLen returns the number of subscribers for the publisher\n\n```go\nfunc (p *Publisher) Publish(v interface{})\n```\nPublish sends the data in v to all subscribers currently registered with the publisher.\n\n```go\nfunc (p *Publisher) Subscribe() chan interface{}\n```\nSubscribe adds a new subscriber to the publisher returning the channel.\n\n```go\nfunc (p *Publisher) SubscribeTopic(topic topicFunc) chan interface{}\n```\nSubscribeTopic adds a new subscriber that filters messages sent by a topic.\n\n","path":"github.com/hyperhq/hypercli/pkg/pubsub","name":"pubsub","synopsis":"","isRedistributable":true}
