server

package
v0.0.0-...-f7ad032 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0, MIT Imports: 10 Imported by: 6

Documentation

Overview

Package server provides a basic control server interface.

Note that no objects are registered by default. Users must provide their own implementations of the control interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSocket

func CreateSocket(addr string) (int, error)

CreateSocket creates a socket that can be used with control server, but doesn't start control server. 'addr' must be a valid and unique abstract socket name. Returns socket's FD, -1 in case of error.

Types

type Server

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

Server is a basic control server.

func Create

func Create(addr string) (*Server, error)

Create creates a new control server with an abstract unix socket with the given address, which must must be unique and a valid abstract socket name.

func CreateFromFD

func CreateFromFD(fd int) (*Server, error)

CreateFromFD creates a new control bound to the given 'fd'. It has no registered interfaces and will not start serving until StartServing is called.

func New

func New(socket *unet.ServerSocket) *Server

New returns a new bound control server.

func (*Server) FD

func (s *Server) FD() int

FD returns the file descriptor that the server is running on.

func (*Server) Register

func (s *Server) Register(obj any)

Register registers a specific control interface with the server.

func (*Server) ResetServer

func (s *Server) ResetServer()

ResetServer resets the server, clearing all registered objects. It stops the old server asynchronously.

func (*Server) StartServing

func (s *Server) StartServing() error

StartServing starts listening for connect and spawns the main service goroutine for handling incoming control requests. StartServing does not block; to wait for the control server to exit, call Wait.

func (*Server) Stop

func (s *Server) Stop(timeout time.Duration)

Stop stops the server. Note that this function should only be called once and the server should not be used afterwards.

func (*Server) Wait

func (s *Server) Wait()

Wait waits for the main server goroutine to exit. This should be called after a call to Serve.

Jump to

Keyboard shortcuts

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