Documentation ¶
Index ¶
- type Callback
- type Message
- type PubSubTransporterMock
- func (m *PubSubTransporterMock) Connect() error
- func (m *PubSubTransporterMock) Connection() *websocket.Conn
- func (m *PubSubTransporterMock) Disconnect() error
- func (m *PubSubTransporterMock) IsConnected() bool
- func (m *PubSubTransporterMock) Publish(message Message) error
- func (m *PubSubTransporterMock) Subscribe(topic string, cb Callback) error
- func (m *PubSubTransporterMock) Unsubscribe(topic string) error
- type PubSubWebsocketTransporter
- type Publisher
- type Subscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
Callback is a function that will be executed after reading a message from a certain topic.
type Message ¶
type Message struct { // Operation is the operation request that will be performed in the websocket server. // // auth: Authorize connection to the websocket server. // // sub: Subscribe to a certain topic. // // topics: List the available topics. // // pub: Publish to a certain topic - Not implemented yet. // // protos: Request message definitions. Operation string // Topic is the name of the topic to subscribe or publish to. Topic string // Type is the name of the ign-msgs protobuf type used to marshal/unmarshal payloads. Type string // Payload is the actual message. This message needs to be unmarshalled with protobuf before using. Payload string }
Message represents a message format for Ignition Robotics websocket server communication.
func NewAuthorizationMessage ¶
NewAuthorizationMessage creates a new authorization message from the given token.
func NewMessageFromByteSlice ¶
NewMessageFromByteSlice initializes a new message from the given slice. It returns an error if the slice is invalid
func NewPublicationMessage ¶
NewPublicationMessage creates a new publication message with a certain type to send to the given topic. messageType is the name of a protobuf type used to marshal the message.
func NewSubscriptionMessage ¶
NewSubscriptionMessage creates a new subscription message from the given topic.
func (*Message) GetPayload ¶
GetPayload returns the message payload.
func (Message) ToByteSlice ¶
ToByteSlice converts the message into a slice of bytes.
type PubSubTransporterMock ¶
PubSubTransporterMock implements PubSubWebsocketTransporter to be used as mock for testing purposes.
func NewPubSubTransporterMock ¶
func NewPubSubTransporterMock() *PubSubTransporterMock
NewPubSubTransporterMock initializes a new PubSubTransporterMock
func (*PubSubTransporterMock) Connect ¶
func (m *PubSubTransporterMock) Connect() error
Connect is a mock for the Connect method.
func (*PubSubTransporterMock) Connection ¶
func (m *PubSubTransporterMock) Connection() *websocket.Conn
Connection is a mock for the Connection method.
func (*PubSubTransporterMock) Disconnect ¶
func (m *PubSubTransporterMock) Disconnect() error
Disconnect is a mock for the Disconnect method.
func (*PubSubTransporterMock) IsConnected ¶
func (m *PubSubTransporterMock) IsConnected() bool
IsConnected is a mock for the IsConnected method.
func (*PubSubTransporterMock) Publish ¶
func (m *PubSubTransporterMock) Publish(message Message) error
Publish is a mock for the Publish method.
func (*PubSubTransporterMock) Subscribe ¶
func (m *PubSubTransporterMock) Subscribe(topic string, cb Callback) error
Subscribe is a mock for the Subscribe method.
func (*PubSubTransporterMock) Unsubscribe ¶
func (m *PubSubTransporterMock) Unsubscribe(topic string) error
Unsubscribe is a mock for the Unsubscribe method.
type PubSubWebsocketTransporter ¶
type PubSubWebsocketTransporter interface { transport.WebsocketTransporter Subscriber Publisher }
PubSubWebsocketTransporter represents a set of methods to communicate two processes using the Publisher and Subscriber interfaces.
func NewIgnWebsocketTransporter ¶
func NewIgnWebsocketTransporter(baseCtx context.Context, host, path, scheme, token string) (PubSubWebsocketTransporter, error)
NewIgnWebsocketTransporter initializes a new PubSubWebsocketTransporter instance using a websocketPubSubTransport implementation. It also establishes a connection to the given addr and sends an authorization message with the given token. The token should be the same as the simulation authorization token from the simulation that the transporter is attempting to connect to.