Documentation
¶
Index ¶
Constants ¶
const ( MsgEvents = iota MsgClose )
const ( ConnActive = iota ConnPending )
Variables ¶
This section is empty.
Functions ¶
func NewProxyModule ¶
func NewProxyModule(moduleID stdtypes.ModuleID, addr string) modules.PassiveModule
NewProxyModule returns a new module that serves as a local proxy to an external module hosted on a module server. The addr parameter specifies the full URL (address and path) of the module at the server. The connection between the proxy and the module server is established when the module receives stdevents.Init, At which time the server must be running and accepting new connections.
Types ¶
type Connection ¶
Connection represents a connection to a particular module at a particular module server. It is used to send events to and receive events from it.
func Connect ¶
func Connect(ctx context.Context, addr string) (*Connection, error)
Connect establishes and returns a new connection to a module server at address addr (in the form of "ws://server:port/path"). The path component of the address is used to specify which module at the module server to connect to. When ctx is canceled before the connection is established, connecting aborts.
func (*Connection) Close ¶
func (c *Connection) Close(ctx context.Context) error
Close closes the connection to the remote module.
func (*Connection) Submit ¶
func (c *Connection) Submit(ctx context.Context, events *stdtypes.EventList) (*stdtypes.EventList, error)
Submit sends the given events to the remote module, waits until the remote module processes them, and returns the resulting events produced by the remote module. One can see it as the proxy for the remote module's ApplyEvents method.
type ControlMessage ¶
type ControlMessage struct {
MsgType controlMessageType
NumEvents int // Only used for EVENT_LIST type.
}
func (*ControlMessage) Bytes ¶
func (cm *ControlMessage) Bytes() []byte
type ModuleHandler ¶
type ModuleHandler struct {
// contains filtered or unexported fields
}
ModuleHandler implements a handler function for an incoming connection at the module server for a PassiveModule.
func NewHandler ¶
func NewHandler(path string, module modules.PassiveModule) *ModuleHandler
NewHandler allocates and returns a pointer to a new ModuleHandler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements a HTTP server containing remote modules.
func NewServer ¶
func NewServer(moduleHandlers ...*ModuleHandler) *Server
NewServer returns a new Server containing the given moduleHandlers which define the modules operated by the server. Each handler associates a module with a path under which the module will be accessible.
func (*Server) Serve ¶
Serve starts the module server, making it listen to new connections at the given address and port (e.g., "0.0.0.0:8080"). Serve blocks until the Stop method is called. It is therefore expected to call Serve in a separate goroutine.