ipc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServerNotRunning = errors.New("server not listening")

Functions

func Send

func Send[T, R any](ctx context.Context, msg T, address string) (R, error)

Send sends a message of type T to the specified address and waits for a response of type R.

Types

type HandlerFunc

type HandlerFunc[T, R any] func(T) (R, error)

func (HandlerFunc[T, R]) Handle

func (h HandlerFunc[T, R]) Handle(msg T) (R, error)

type MessageHandler

type MessageHandler[T, R any] interface {
	Handle(msg T) (R, error)
}

MessageHandler defines an interface for processing a message of type T and returning a result of type R.

type SocketServer

type SocketServer[T, R any] struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer[T, R any](address string, handler MessageHandler[T, R]) *SocketServer[T, R]

NewServer creates a new socket server instance listening on the provided address. The server will offload received messages to the handler for processing.

func (*SocketServer[T, R]) Run

func (s *SocketServer[T, R]) Run(ctx context.Context) error

Run starts the server and blocks until the context is cancelled.

Jump to

Keyboard shortcuts

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