Documentation ¶
Index ¶
- Constants
- Variables
- func GetDefaultClientConnectWait() int
- func Sleep()
- type Actor
- func (a *Actor) Close()
- func (a *Actor) Read() (*Message, error)
- func (a *Actor) ReadTimed(duration time.Duration) (*Message, error)
- func (a *Actor) ReadTimedTimeoutMessage(duration time.Duration, onTimeoutMessage *Message) (*Message, error)
- func (a *Actor) Status() string
- func (a *Actor) StatusCode() Status
- func (a *Actor) String() string
- func (a *Actor) Write(msgType int, message []byte) error
- func (a *Actor) WriteMessage(msg *Message) error
- type ActorConfig
- type Client
- type ClientConfig
- type ConnectionPool
- func (sm *ConnectionPool) Close()
- func (sm *ConnectionPool) MapExec(callback func(*Server), from string)
- func (sm *ConnectionPool) Read(callback func(*Server, *Message, error))
- func (sm *ConnectionPool) ReadTimed(duration time.Duration, callback func(*Server, *Message, error))
- func (sm *ConnectionPool) ReadTimedFastest(duration time.Duration, callback func(*Server, *Message, error))
- type Message
- type Server
- type ServerConfig
- type Status
Constants ¶
const ( VERSION = 2 // ipc package VERSION MAX_MSG_SIZE = 3145728 // 3Mb - Maximum bytes allowed for each message DEFAULT_WAIT = 10 DEFAULT_LOG_LEVEL = logrus.ErrorLevel // SOCKET_NAME_BASE = "/tmp/" SOCKET_NAME_EXT = ".sock" CLIENT_CONNECT_MSGTYPE = 12 ENCRYPT_BY_DEFAULT = true )
Variables ¶
var TimeoutMessage = &Message{MsgType: 2, Err: errors.New("timed_out")}
Functions ¶
func GetDefaultClientConnectWait ¶ added in v1.2.6
func GetDefaultClientConnectWait() int
Types ¶
type Actor ¶ added in v1.2.6
type Actor struct {
// contains filtered or unexported fields
}
func NewActor ¶ added in v1.2.6
func NewActor(ac *ActorConfig) Actor
func (*Actor) Read ¶ added in v1.2.6
Read - blocking function, reads each message received if MsgType is a negative number it's an internal message
func (*Actor) ReadTimedTimeoutMessage ¶ added in v1.3.4
func (*Actor) StatusCode ¶ added in v1.2.6
StatusCode - returns the current connection status
func (*Actor) Write ¶ added in v1.2.6
Write - writes a message to the ipc connection. msgType - denotes the type of data being sent. 0 is a reserved type for internal messages and errors.
func (*Actor) WriteMessage ¶ added in v1.3.4
type ActorConfig ¶ added in v1.2.6
type ActorConfig struct { IsServer bool ServerConfig *ServerConfig ClientConfig *ClientConfig }
type Client ¶
Client - holds the details of the client connection and config.
func StartClient ¶
func StartClient(config *ClientConfig) (*Client, error)
StartClient - start the ipc client. ipcName = is the name of the unix socket or named pipe that the client will try and connect to.
func StartClientPool ¶ added in v1.3.4
func StartClientPool(config *ClientConfig) (*Client, error)
type ClientConfig ¶
type ClientConfig struct { Name string Timeout time.Duration // the duration to wait before abandoning a dial attempt RetryTimer time.Duration // the duration to wait in dial loop iteration and reconnect attempts LogLevel string MultiClient bool Encryption bool }
ClientConfig - used to pass configuration overrides to ClientStart()
type ConnectionPool ¶ added in v1.3.4
type ConnectionPool struct { Servers []*Server ServerConfig *ServerConfig Logger *logrus.Logger // contains filtered or unexported fields }
func (*ConnectionPool) Close ¶ added in v1.3.4
func (sm *ConnectionPool) Close()
func (*ConnectionPool) MapExec ¶ added in v1.3.4
func (sm *ConnectionPool) MapExec(callback func(*Server), from string)
func (*ConnectionPool) Read ¶ added in v1.3.4
func (sm *ConnectionPool) Read(callback func(*Server, *Message, error))
func (*ConnectionPool) ReadTimed ¶ added in v1.3.4
func (sm *ConnectionPool) ReadTimed(duration time.Duration, callback func(*Server, *Message, error))
ReadTimed will call ReadTimed on all connections waiting for the slowest one to finish
func (*ConnectionPool) ReadTimedFastest ¶ added in v1.3.4
func (sm *ConnectionPool) ReadTimedFastest(duration time.Duration, callback func(*Server, *Message, error))
ReadTimed will call ReadTimed on all connections waiting for the fastest one to finish
type Message ¶
type Message struct { Err error // details of any error MsgType int // 0 = reserved , -1 is an internal message (disconnection or error etc), all messages received will be > 0 Data []byte // message data received Status string // the status of the connection }
Message - contains the received message
type Server ¶
type Server struct { Actor Connections *ConnectionPool // contains filtered or unexported fields }
Server - holds the details of the server connection & config.
func StartServer ¶
func StartServer(config *ServerConfig) (*Server, error)
StartServer - starts the ipc server.
func StartServerPool ¶ added in v1.3.4
func StartServerPool(config *ServerConfig) (*Server, error)
type ServerConfig ¶
type ServerConfig struct { Name string MaxMsgSize int UnmaskPermissions bool LogLevel string MultiClient bool Encryption bool }
ServerConfig - used to pass configuration overrides to ServerStart()