server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Telemetry *config.TelemetryConfig
	Server    *config.AssistantServerConfig
}

type RunmeHandler

type RunmeHandler struct {
	Ctx    context.Context
	Conn   *websocket.Conn
	Runner *Runner
	// contains filtered or unexported fields
}

RunmeHandler is a processor for messages received over a websocket from a single RunmeConsole element in the DOM.

There is one instance of this struct per websocket connection; i.e. each instance handles a single websocket connection. There is also 1 websocket connection per RunmeConsole element (block) in the UI. So this RunmeHandler is only handling one UI block. However, multiple commands can be sent over the websocket connection. Right now we only support non-interactive commands. So the protocol is client sends a single ExecuteRequest and then the server responds with multiple ExecuteResponses. The runnerv2service.Execute method is invoked once per ExecuteRequest; it will terminate when execution finishes. However, the UI could send additional ExecuteRequests over the same websocket connection. These could be a stop/terminate message to indicate we should abort a long running command.

However, we should also be robust to the case where the UI erroneously sends a new request before the current one has finished.

func NewRunmeHandler

func NewRunmeHandler(ctx context.Context, conn *websocket.Conn, runner *Runner) *RunmeHandler

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner lets you run commands using Runme.

func NewRunner

func NewRunner(logger *zap.Logger) (*Runner, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the main server for the cloud assistant

func NewServer

func NewServer(opts Options, agent *ai.Agent) (*Server, error)

NewServer creates a new server

func (*Server) Run

func (s *Server) Run() error

Run starts the http server Blocks until its shutdown.

type SocketMessageProcessor

type SocketMessageProcessor struct {
	Ctx              context.Context
	Conn             *websocket.Conn
	ExecuteRequests  chan *v2.ExecuteRequest
	ExecuteResponses chan *v2.ExecuteResponse
	// StopReading is used to signal to the readMessages goroutine that it should stop reading messages
	StopReading chan bool

	Runner *Runner
}

func NewSocketMessageProcessor

func NewSocketMessageProcessor(ctx context.Context) *SocketMessageProcessor

func (*SocketMessageProcessor) Context

func (p *SocketMessageProcessor) Context() context.Context

func (*SocketMessageProcessor) Recv

func (*SocketMessageProcessor) RecvMsg

func (p *SocketMessageProcessor) RecvMsg(m any) error

func (*SocketMessageProcessor) Send

Send sends a response message to the client. The server handler may call Send multiple times to send multiple messages to the client. An error is returned if the stream was terminated unexpectedly, and the handler method should return, as the stream is no longer usable.

func (*SocketMessageProcessor) SendHeader

func (p *SocketMessageProcessor) SendHeader(md metadata.MD) error

func (*SocketMessageProcessor) SendMsg

func (p *SocketMessageProcessor) SendMsg(m any) error

func (*SocketMessageProcessor) SetHeader

func (p *SocketMessageProcessor) SetHeader(md metadata.MD) error

func (*SocketMessageProcessor) SetTrailer

func (p *SocketMessageProcessor) SetTrailer(md metadata.MD)

type WebSocketHandler

type WebSocketHandler struct {
	// contains filtered or unexported fields
}

WebSocketHandler is a handler for websockets.

func (*WebSocketHandler) Handler

func (h *WebSocketHandler) Handler(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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