Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNatsExceedMaxReconnects says number of reconnect attempts exceed ErrNatsExceedMaxReconnects = errors.New("pubnats: exceed max reconnects") )
var ( // RegexNotWatch sets the file extension to avoid watching RegexNotWatch = regexp.MustCompile("(?:^tailer\\.|^gobzip-|^\\..+\\.swp$|\\.gz$|\\.[0-9]$)") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { FileGlob string `json:"fileglob,omitempty"` Match string `json:"match,omitempty"` IgnorePattern string `json:"ignore,omitempty"` Polling bool `json:"polling,omitempty"` }
Config describe what we want and publish
type Emitter ¶
Emitter will emit Nats messages
func NewFileEmitter ¶
NewFileEmitter return a new FileEmitter
type FileEmitter ¶
type FileEmitter struct {
// contains filtered or unexported fields
}
FileEmitter print to file, separated by time
type MessageQueue ¶
type MessageQueue struct {
// contains filtered or unexported fields
}
MessageQueue handles the file events
func NewMessageQueue ¶
func NewMessageQueue(maxMessages int64) *MessageQueue
NewMessageQueue returns a new MessageQueue
func (*MessageQueue) Len ¶
func (mq *MessageQueue) Len() int64
Len returns current MessageQueue length
type NatsPublisher ¶
type NatsPublisher struct { URL string // contains filtered or unexported fields }
NatsPublisher will Publish messages via nats
func (*NatsPublisher) Publish ¶
func (n *NatsPublisher) Publish(msg []byte) error
Publish publish the message to server
func (*NatsPublisher) SetTopic ¶
func (n *NatsPublisher) SetTopic(topic string)
SetTopic sets the publish topic
type NatsSubscriber ¶
type NatsSubscriber struct {
// contains filtered or unexported fields
}
NatsSubscriber will Subscribe messages via nats
func (*NatsSubscriber) Bind ¶
func (n *NatsSubscriber) Bind(mq *MessageQueue)
Bind to the specified message queue
func (*NatsSubscriber) LastError ¶
func (n *NatsSubscriber) LastError() (err error)
LastError stats the latest error
func (*NatsSubscriber) Subscribe ¶
func (n *NatsSubscriber) Subscribe(topic string) error
Subscribe the topic and push to the message queue
type Publisher ¶
Publisher will Publish messages
func NewNatsPublisher ¶
NewNatsPublisher return a Publisher using nats
type SimplePublisher ¶
type SimplePublisher struct { }
SimplePublisher use fmt.Println to publish
func (*SimplePublisher) Publish ¶
func (f *SimplePublisher) Publish(msg []byte) error
Publish call fmt.Println to print the msg
func (*SimplePublisher) SetTopic ¶
func (f *SimplePublisher) SetTopic(topic string)
SetTopic NOOP for fmt
type SimpleSubscriber ¶
type SimpleSubscriber struct { }
SimpleSubscriber use fmt.Println to handle the received msg
func (*SimpleSubscriber) Bind ¶
func (f *SimpleSubscriber) Bind(mq *MessageQueue)
Bind to the specified message queue
func (*SimpleSubscriber) LastError ¶
func (f *SimpleSubscriber) LastError() error
LastError stats the latest error
func (*SimpleSubscriber) Subscribe ¶
func (f *SimpleSubscriber) Subscribe(topic string) error
Subscribe for specified topic
type StdoutEmitter ¶
type StdoutEmitter struct { }
StdoutEmitter use fmt.Println to publish
type Subscriber ¶
type Subscriber interface { Subscribe(topic string) error Bind(mq *MessageQueue) Close() LastError() error }
Subscriber will Subscribe messages and do things
func NewNatsSubscriber ¶
func NewNatsSubscriber(url string) (Subscriber, error)
NewNatsSubscriber return a Subscriber using nats