Documentation ¶
Index ¶
- Constants
- func NewHeader(key string, value []byte) *message.Header
- func NewMessage(key, value []byte, headers []*message.Header) *message.Message
- type Config
- type Consumer
- func (c *Consumer) Poll() Event
- func (c *Consumer) ReadMessage() (*message.Message, error)
- func (c *Consumer) Start()
- func (c *Consumer) Stop()
- func (c *Consumer) Subscribe(topic string) error
- func (c *Consumer) SubscribeTopics(topics []string) error
- func (c *Consumer) Topics() []string
- func (c *Consumer) Unsubscribe(topic string) error
- func (c *Consumer) UnsubscribeTopics(topics []string) error
- type Error
- type Event
- type IPFSClient
- type Producer
- func (p *Producer) AddTopic(topic string)
- func (p *Producer) AddTopics(topics []string)
- func (p *Producer) Produce(topic string, msg *message.Message) error
- func (p *Producer) ProduceAll(msg *message.Message) error
- func (p *Producer) RemoveTopic(topic string)
- func (p *Producer) RemoveTopics(topics []string)
- func (p *Producer) Topics() []string
Constants ¶
const ( HYDRA_IPFS_READ_RECORD_ERROR = iota + 1 HYDRA_RECORD_UNMARSHAL_ERROR = iota HYDRA_RESPONSE_TIMEOUT_ERROR = iota HYDRA_ZERO_BYTES_RECIEVED_ERROR = iota )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
Config holds the needed values for either a producer or consumer to connect to an IPFS client and a initial set of topics that the producer or consumer are subscribed on creation.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a hydra config that points to localhost:5001 and has no topics configured to pull from.
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer "consumes" all topic messages that it is subscribed to. It provides a high level interface for topic management and pulling messages from IPFS pubsub.
func NewConsumer ¶
func NewConsumer(client IPFSClient, config *Config) (*Consumer, error)
NewConsumer creates a new consumer that is connected to a IPFS client via the configuration passed and also is subscribed to any topics set in the config.
func (*Consumer) ReadMessage ¶
ReadMessage will wait until there is a message from any one of the subscribed topics and return that message.
func (*Consumer) Start ¶
func (c *Consumer) Start()
Start will start the consumption of all messages from the topics that the consumer is subscribed to. This needs to be called before attempting to read any messages.
func (*Consumer) Stop ¶
func (c *Consumer) Stop()
Stop will stop the consumer from reading any more messages from the topics that it is subscribed to.
func (*Consumer) Subscribe ¶
Subscribe add a topic to the consumers list of topics and will allow messages to be consumed from those topics.
func (*Consumer) SubscribeTopics ¶
SubscribeTopics adds a list of topics that the consumer will consume messages from.
func (*Consumer) Topics ¶
Topics returns the current list of topics that the consumer is subscribed to.
func (*Consumer) Unsubscribe ¶
Unsubscribe removes a topic from the list of topics that the conumser is consuming.
func (*Consumer) UnsubscribeTopics ¶
UnsubscribeTopics removes a list of topics from the list of topvs that the consumer is consuming.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represent a general error returned from the reading or writing of a message to IPFS pubsub.
type Event ¶
type Event interface {
String() string
}
Event defines either an error or message passed from IPFS pubsub.
type IPFSClient ¶
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
Producer is a high level message producer that publishes messages to a single or multiple topics on IPFS pubsub.
func NewProducer ¶
func NewProducer(client IPFSClient, config *Config) *Producer
NewProducer creates a new producer connected to a IPFS client specified in the configuration.
func (*Producer) AddTopic ¶
AddTopic will add a topic to the list of topics the producer will publish messages to.
func (*Producer) AddTopics ¶
AddTopics will add a list of topics to the list of topics the producer will publish messages to.
func (*Producer) Produce ¶
Produce will publish a message to a specific topic on IPFS. If the topic provided is not in producers list of subscribed topics it will throw an error.
func (*Producer) ProduceAll ¶
ProduceAll will publish a message to all of the topics that the producer is subscribed to.
func (*Producer) RemoveTopic ¶
RemoveTopic will will remove a topic from the producers list of topics.
func (*Producer) RemoveTopics ¶
RemoveTopics removes a list of topics from the producers list of topics.