domainsockets

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package domainsockets prvoides for a unix domain socket server, similar to an RPC server like Grpc except that it is intended to only connect unix processes on the same device.

Usage

Usage is fairly simple:

s, err := NewServer()
if err != nil {
  // Do something
}

s.Register(header, handler)

if err := s.Start(); err != nil {
  // Do something
}

Index

Constants

View Source
const (
	DataPacket  uint64 = 0
	DataClose   uint64 = 1
	DataHandler uint64 = 2
	KeepAlive   uint64 = 3
)

Various tlv types.

View Source
const (
	MiB = 1048576
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	ID      uint64
	Handler string
	Data    *bytes.Buffer
}

Call represents the input/output for a procedure calls. If input, Data represents the input arguments. If output, it represents the return data.

type Handler

type Handler func(req *Call) *Call

Handler provides a function that answers a request from a client and returns a response.

type Server

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

Server provides a Unix Domain Socket procedure calling service.

func NewServer

func NewServer(setupSocket string) (*Server, error)

New is the constructor for Server.

func (*Server) Close

func (s *Server) Close()

Close closes all connections. This server object cannot be reused.

func (*Server) Register

func (s *Server) Register(name string, h Handler) error

Register registers a handler. This should only be called before Start(), otherwise the results are undetermined.

func (*Server) Start

func (s *Server) Start()

type ServerMsg

type ServerMsg struct {
	ID    uint64
	Type  uint64
	Error error
	Data  []byte
}

ServerMsg represents a message returned by the message handler.

Jump to

Keyboard shortcuts

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