Documentation ¶
Index ¶
Constants ¶
const ( // DefaultSend is the default tcp address for sending data to the server. DefaultSend = "tcp://localhost:61124" // DefaultRecv is the default tcp address for recieving data from the server. DefaultRecv = "tcp://localhost:61123" )
Variables ¶
var NoopHandler = MsgHandler{MatchHandler: HandlerFunc(func(r Result, m Message, c Communication) {})}
Functions ¶
This section is empty.
Types ¶
type Communication ¶
type Communication struct {
// contains filtered or unexported fields
}
func (*Communication) Send ¶
func (c *Communication) Send(line string, message Message)
type Config ¶
type Config struct { Name string `json:"name"` Version string `json:"version"` UUID string `json:"uuid"` Service ServiceConfig `json:"service"` }
Config holds configuration values passed into quasar on bootstrap. Recommended way to use this object is to unmarshal some JSON into an instance. You can also build this by hand using flags.
func NewConfigFromJSONFile ¶
NewConfigFromJSONFile takes a file path to a JSON file and unmarshals it into a new Config instance.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(conf *Config) (*Connection, error)
type Handler ¶
type Handler interface {
HandleMatch(Result, Message, Communication)
}
Handler is an interface that has a Handle method that takes a Result and Message as arguments. What you do with these is up to you. This is a function that will be triggered if it's matcher returns a valid match.
func PrivmsgMiddlware ¶
type HandlerFunc ¶
type HandlerFunc func(Result, Message, Communication)
func (HandlerFunc) HandleMatch ¶
func (fn HandlerFunc) HandleMatch(r Result, m Message, c Communication)
type Matcher ¶
Matcher is an interface that has a match method that receives a Message and tries to match it against a set of rules. If no match is found, then you should return nil.
type MatcherFunc ¶
MatcherFunc registers the wrapped function as a Matcher.
func (MatcherFunc) Match ¶
func (fn MatcherFunc) Match(msg Message) Result
type MsgHandler ¶
type RegexMatcher ¶
type RegexMatcher struct {
// contains filtered or unexported fields
}
RegexMatcher satisfies the Matcher interface and will match messages against a provided list of regular expressions.
func NewRegexMatcher ¶
func NewRegexMatcher(expressions ...string) RegexMatcher
NewRegexMatcher will return a new RegexMatcher setup with expressions
func (RegexMatcher) Match ¶
func (r RegexMatcher) Match(msg Message) Result
type Service ¶
type Service struct { Name string UUID string Description string HelpText string Config *Config // contains filtered or unexported fields }
Service is the state of the service. It holds the handlers and matchers and helps relay messages to the right handler when they come in from the Tenyks server.
func (*Service) Cleanup ¶
func (s *Service) Cleanup()
Cleanup will close open connections and clean up anything that shouldn't linger after shutdown.
func (*Service) DefaultHandle ¶
func (s *Service) DefaultHandle(handler MsgHandler)
func (*Service) Handle ¶
func (s *Service) Handle(handler MsgHandler)
type ServiceConfig ¶
type ServiceConfig struct { // SendAddr is the host and port in a TCP URL format: tcp://localhost:61124. // If the SendAddr string is blank, the default tenyks port is used. SendAddr string `json:"send_addr"` // RecvAddr is the host and port in a TCP URL format: tcp://localhost:61124. // If the RecvAddr string is blank, the default tenyks port is used. RecvAddr string `json:"recv_addr"` }
ServiceConfig holds the addresses for pubsub actions