ipc

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ipc is a helper for passing Cobra commands across a Unix domain socket (UDS).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(path, msg string) (string, error)

Send is invoked when a caller wants to connect to an IPCServer listening on the provided path to issue a command as described by the provided msg.

Types

type Client added in v0.4.9

type Client struct {
	Foreground bool
	RespCB     func(string) bool
	// contains filtered or unexported fields
}

Client is the type used when communicating with an IPCServer.

func (*Client) Close added in v0.4.9

func (c *Client) Close()

Close will terminate the connection.

func (*Client) Send added in v0.4.9

func (c *Client) Send(path, msg string) error

Send can be invoked on a custom Client with an optional mechanism for processing responses and whether to work in the foreground instead of a Goroutine.

type ConnWriter

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

ConnWriter is an io.Writer that will relay any bytes written to it into the associated connection.

func (*ConnWriter) Write

func (cw *ConnWriter) Write(p []byte) (int, error)

Write will write bytes to the connection.

func (*ConnWriter) Writeln

func (cw *ConnWriter) Writeln(format string, args ...any)

Writeln will write a formatted message to the connection.

type IPCServer

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

IPCServer is the type to set up and listen for clients that want to relay commands for the server to execute.

func (*IPCServer) Start

func (ipc *IPCServer) Start(ctx context.Context, log *zerolog.Logger, path string, cmd *cobra.Command) error

Start will set up and listen on a Unix domain socket (UDS) located at the provided path until the context provided is canceled. Any clients that attach may issue string commands which will be parsed and processed by the provided Cobra command.

func (*IPCServer) Stop

func (ipc *IPCServer) Stop() error

Stop will close any client connections outstanding as well as the Unix domain socket (UDS) listener.

Jump to

Keyboard shortcuts

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