service

package
v0.0.0-...-db1fe24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceOnline  = true
	ServiceOffline = false
)

Variables

View Source
var (
	Logger log15.Logger
)

Functions

This section is empty.

Types

type Connection

type Connection struct {
	In  <-chan string
	Out chan<- string
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conf config.ServiceConfig) (*Connection, error)

func (*Connection) ByeServiceHandler

func (c *Connection) ByeServiceHandler(msg *Message)

func (*Connection) HelpIrcHandler

func (c *Connection) HelpIrcHandler(conn *irc.Connection, msg *irc.Message)

func (*Connection) InfoIrcHandler

func (c *Connection) InfoIrcHandler(conn *irc.Connection, msg *irc.Message)

func (*Connection) Init

func (c *Connection) Init() error

func (*Connection) ListServicesIrcHandler

func (c *Connection) ListServicesIrcHandler(conn *irc.Connection, msg *irc.Message)

func (*Connection) PingServices

func (c *Connection) PingServices()

func (*Connection) PongServiceHandler

func (c *Connection) PongServiceHandler(msg *Message)

func (*Connection) PrivmsgIrcHandler

func (c *Connection) PrivmsgIrcHandler(conn *irc.Connection, msg *irc.Message)

func (*Connection) PrivmsgServiceHandler

func (c *Connection) PrivmsgServiceHandler(msg *Message)

func (*Connection) RegisterIrcHandlers

func (c *Connection) RegisterIrcHandlers(conn *irc.Connection)

RegisterIrcHandlers connects a few callback handlers for PRIVMSG's that respond to things like !services and !help

func (*Connection) RegisterServiceHandler

func (c *Connection) RegisterServiceHandler(msg *Message)

type Message

type Message struct {
	Target       string `json:"target"`
	Command      string `json:"command"`
	Mask         string `json:"mask"`
	Direct       bool   `json:"direct"`
	Nick         string `json:"nick"`
	Host         string `json:"host"`
	Full_message string `json:"full_message"` // Legacy for compat with py version
	User         string `json:"user"`
	From_channel bool   `json:"from_channel"` // Legacy for compat with py version
	Connection   string `json:"connection"`
	Payload      string `json:"payload"`
	Meta         *Meta  `json:"meta"`
}

func NewMessageFromString

func NewMessageFromString(msg string) (message *Message, err error)

type Meta

type Meta struct {
	Name        string     `json:"name"`
	Version     string     `json:"version"`
	SID         *ServiceID `json:"UUID"`
	Description string     `json:"description"`
}

type PubSubReactor

type PubSubReactor struct {
	// contains filtered or unexported fields
}

func NewPubSubReactor

func NewPubSubReactor(conf config.ServiceConfig) (*PubSubReactor, error)

func (*PubSubReactor) Start

func (p *PubSubReactor) Start()

type Service

type Service struct {
	Name           string
	UUID           uuid.UUID
	Version        string
	Description    string
	Online         bool
	LastPing       time.Time
	LastPong       time.Time
	RespondedCount int
}

func NewService

func NewService() *Service

func (*Service) String

func (self *Service) String() string

type ServiceEngine

type ServiceEngine struct {
	Reactor   *PubSubReactor
	ServiceRg *ServiceRegistry
	CommandRg *irc.HandlerRegistry
	// contains filtered or unexported fields
}

func NewServiceEngine

func NewServiceEngine(conf config.ServiceConfig) (*ServiceEngine, error)

func (*ServiceEngine) AddHandler

func (s *ServiceEngine) AddHandler(name string, fn servicefn)

func (*ServiceEngine) NotifyServicesAboutStart

func (self *ServiceEngine) NotifyServicesAboutStart()

NotifyServicesAboutStart that the bot came online. This should prompt services to send the REGISTER command.

func (*ServiceEngine) RegisterIrcHandlersFor

func (self *ServiceEngine) RegisterIrcHandlersFor(conn *irc.Connection)

func (*ServiceEngine) SetIRCConns

func (self *ServiceEngine) SetIRCConns(ircconns irc.IRCConnections)

func (*ServiceEngine) Start

func (self *ServiceEngine) Start()

func (*ServiceEngine) UpdateService

func (self *ServiceEngine) UpdateService(uuid string, status bool)

UpdateService is used to update the service state.

type ServiceID

type ServiceID struct {
	UUID uuid.UUID
}

func (*ServiceID) UnmarshalJSON

func (self *ServiceID) UnmarshalJSON(b []byte) error

type ServiceRegistry

type ServiceRegistry struct {
	// contains filtered or unexported fields
}

func NewServiceRegistry

func NewServiceRegistry() *ServiceRegistry

func (*ServiceRegistry) GetServiceByName

func (self *ServiceRegistry) GetServiceByName(name string) *Service

func (*ServiceRegistry) GetServiceByUUID

func (self *ServiceRegistry) GetServiceByUUID(uuid string) *Service

func (*ServiceRegistry) IsService

func (self *ServiceRegistry) IsService(name string) bool

func (*ServiceRegistry) RegisterService

func (self *ServiceRegistry) RegisterService(srv *Service)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL