Documentation
¶
Index ¶
- type Message
- func (m *Message) CommandID() int
- func (m *Message) Error() error
- func (m *Message) GetRefRequestsChan() chan ReceivedMessageI
- func (m *Message) MsgID() int
- func (m *Message) OK() bool
- func (m *Message) Payload() []byte
- func (m *Message) RefMsgID() int
- func (m *Message) RefSend(cmd int, payload []byte) (SentMessageI, error)
- func (m *Message) RefSendBlock(cmd int, payload []byte) (ReceivedReplyI, error)
- func (m *Message) Reply(cmd int, payload []byte) error
- func (m *Message) SendError(errStr string) error
- func (m *Message) SendOK() error
- func (m *Message) ServiceID() int
- func (m *Message) WaitReply() (ReceivedReplyI, error)
- type MessageGetReplyI
- type MessageI
- type MessageReceivedOKI
- type MessageRefererI
- type MessageReplierI
- type MessageReplyOKErrI
- type ReceivedMessageI
- type ReceivedReplyI
- type SentMessageI
- type Twine
- func (t *Twine) Graceful()
- func (t *Twine) RefRequest(refID int, cmd int, payload []byte) (SentMessageI, error)
- func (t *Twine) RefRequestBlock(refID int, cmd int, payload []byte) (ReceivedReplyI, error)
- func (t *Twine) Reply(msgID int, cmd int, payload []byte) error
- func (t *Twine) ReplyClose(msgID int, ok bool, errStr string) error
- func (t *Twine) Send(servInt int, cmd int, payload []byte) (SentMessageI, error)
- func (t *Twine) SendBlock(servInt int, cmd int, payload []byte) (ReceivedReplyI, error)
- func (t *Twine) Stop()
- func (t *Twine) WaitClose()
- type Unix
- type Websocket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message encapsulates a generic message interface
func (*Message) GetRefRequestsChan ¶
func (m *Message) GetRefRequestsChan() chan ReceivedMessageI
GetRefRequestsChan creates a channel if necessary and returns it
func (*Message) RefSend ¶
func (m *Message) RefSend(cmd int, payload []byte) (SentMessageI, error)
RefSend creates a new message with a reference to the current message
func (*Message) RefSendBlock ¶
func (m *Message) RefSendBlock(cmd int, payload []byte) (ReceivedReplyI, error)
RefSendBlock sends a new mssage referencing anexisting one, and returns with the response or an error
func (*Message) WaitReply ¶
func (m *Message) WaitReply() (ReceivedReplyI, error)
WaitReply returns the reply or error when it eventually arrives
type MessageGetReplyI ¶
type MessageGetReplyI interface {
WaitReply() (ReceivedReplyI, error)
}
MessageGetReplyI adds the ability to wait for the reply to a sent message
type MessageI ¶
type MessageI interface { MsgID() int RefMsgID() int CommandID() int ServiceID() int Payload() []byte }
MessageI is the baseinterface for all Twine message interfaces
type MessageReceivedOKI ¶
MessageReceivedOKI adds getters for OK and Error replies
type MessageRefererI ¶
type MessageRefererI interface { RefSend(int, []byte) (SentMessageI, error) RefSendBlock(int, []byte) (ReceivedReplyI, error) GetRefRequestsChan() chan ReceivedMessageI }
MessageRefererI adds the abilty to send and receive new Requests that reference the message
type MessageReplierI ¶
MessageReplierI adds teh ability to reply to an incoming message
type MessageReplyOKErrI ¶
MessageReplyOKErrI adds the ability to reply with OK and (someday) Error This can be a reply to an incoming messgae or to a reply.
type ReceivedMessageI ¶
type ReceivedMessageI interface { MessageI MessageReplierI MessageReplyOKErrI MessageRefererI }
ReceivedMessageI is a message that was initiated on the other side and received here You can reply or create new requests referring the message
type ReceivedReplyI ¶
type ReceivedReplyI interface { MessageI MessageReceivedOKI MessageReplyOKErrI }
ReceivedReplyI is a message received in response to a message sent You can acknowledge with an OK or error.
type SentMessageI ¶
type SentMessageI interface { MessageI MessageGetReplyI MessageRefererI }
SentMessageI is a mesage that was just sent and has the ability to makeadditional requests refering this message, and wait for replies
type Twine ¶
type Twine struct { ReadyChan chan struct{} MessageChan chan ReceivedMessageI ErrorChan chan error // contains filtered or unexported fields }
Twine holds everything needed for the protocol to function
func NewUnixClient ¶
NewUnixClient creates a new Twine struct configured to be a client
func NewUnixServer ¶
NewUnixServer creates a new Twine struct configured to be a server This returns once server is listening; use ReadyChan to know when a handshake has been made
func NewWebsocketServer ¶
NewWebsocketServer returns a Twine instance from an http request
func (*Twine) Graceful ¶
func (t *Twine) Graceful()
Graceful stops new incoming requests and waits for all messages to terminate before shutting down.
func (*Twine) RefRequest ¶
RefRequest sneds a new message with a reference to an open message
func (*Twine) RefRequestBlock ¶
RefRequestBlock sends a new message with a reference to an open message and blocks until a reply is received
func (*Twine) ReplyClose ¶
ReplyClose sends an OK and closes the message
func (*Twine) Send ¶
Send a new message Shouldn't you get a callback, or should you pass a callback?
type Unix ¶
type Unix struct {
// contains filtered or unexported fields
}
Unix is the unix domain socket transport for Twine
func (*Unix) ReadMessage ¶
ReadMessage returns an incoming message after it has arrived
func (*Unix) StartServer ¶
StartServer blocks until a peer has connected
type Websocket ¶
type Websocket struct { ErrorChan chan (error) // contains filtered or unexported fields }
Websocket is a transport for Twine
func (*Websocket) Close ¶
func (w *Websocket) Close()
Close the websocket connection and shutdown read and write loops
func (*Websocket) ReadMessage ¶
ReadMessage reuturs the next message or an error This is a problem. Because if you don't call ReadMessage you just hang Should ebe replaced with GetMessageChannel
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package mock_twine is a generated GoMock package.
|
Package mock_twine is a generated GoMock package. |