externalmodule

package
v0.0.0-...-a733917 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgEvents = iota
	MsgClose
)
View Source
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

type Connection websocket.Conn

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

func (ms *Server) Serve(addrPort string) error

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.

func (*Server) ServeHTTP

func (ms *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is a wrapper around the HTTP serveMux's method of the same name, so it can be used as a http.ServeMux.

func (*Server) Stop

func (ms *Server) Stop() error

Stop stops the server, making the call to the Serve method return.

Jump to

Keyboard shortcuts

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