socket

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: EUPL-1.2 Imports: 8 Imported by: 0

Documentation

Overview

Package socket implements socket reading and event distribution.

Index

Constants

View Source
const GroupEventListener = `group:"eventlisteners"`

GroupEventListener is the tag used in DI for eventlisteners.

Variables

View Source
var Module = fx.Module("socket", fx.Provide(New))

Module is the DI module.

Functions

func AsEventListener

func AsEventListener(handler any) any

AsEventListener converts type to an EventListener for DI.

Types

type Config

type Config struct {
	Path string `hcl:"path"`
}

Config is the configuration for the socket location.

type EventListener

type EventListener interface {
	Message(message string)
	Close()
}

EventListener receives IPC messages.

type Opts

type Opts struct {
	fx.In

	Logger    *slog.Logger
	Config    Config
	LC        fx.Lifecycle
	Listeners []EventListener `group:"eventlisteners"`
}

Opts is the dependencies for Reader.

type Reader

type Reader struct {
	Logger    *slog.Logger
	Listeners []EventListener
	// contains filtered or unexported fields
}

Reader reads the socket and parses the messages.

func New

func New(o Opts) (*Reader, error)

New constructs a new Reader.

func (*Reader) Start

func (s *Reader) Start()

Start reads the underlying socket.

func (*Reader) Stop

func (s *Reader) Stop() func() error

Stop closes the connection and signals the EventListener to stop receiving messages.

Jump to

Keyboard shortcuts

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