rpc

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToJSONT

func AnyToJSONT[T any](input any) (T, error)

func ServerRoute

func ServerRoute(s *Server, rpcFunction RPCFunction, args any) (any, error)

func ServerStart

func ServerStart(s *Server) error

func SlogJSON

func SlogJSON(key string, value any) slog.Attr

Types

type AgentPingArgs

type AgentPingArgs struct {
	Ping string
}

type AgentPingResult

type AgentPingResult struct {
	Ping string
	Pong string
}

func AgentPing

func AgentPing(args AgentPingArgs) (AgentPingResult, error)

type ExecArgs

type ExecArgs struct {
	Command     []string
	Dir         string
	Environment map[string]string
	Stdin       []byte
}

type ExecResult

type ExecResult struct {
	Stdout   []byte
	Stderr   []byte
	ExitCode int
	Pid      int
}

func Exec

func Exec(args ExecArgs) (ExecResult, error)

type FileStatArgs

type FileStatArgs struct {
	Path              string
	FollowSymlinks    bool
	CalculateChecksum bool
}

type FileStatResult

type FileStatResult struct {
	// always returned
	Path   string
	Exists bool

	// usually returned
	BaseName     string
	Size         int64
	FileMode     fs.FileMode
	ModifiedTime time.Time

	// depends on FileInfo.Sys()
	AccessTime time.Time
	CreateTime time.Time
	Dev        uint64
	Gid        uint64
	GroupName  string
	Inode      uint64
	Nlink      uint64
	Uid        uint64
	UserName   string

	// conditional on CalculateChecksum
	SHA256Checksum string
}

func FileStat

func FileStat(args FileStatArgs) (FileStatResult, error)

type RPCCall

type RPCCall[T any] struct {
	UUID        string
	RPCFunction RPCFunction
	Args        T
}

type RPCFunction

type RPCFunction string
const (
	RPCAgentPing RPCFunction = "AgentPing"
	RPCClose     RPCFunction = "Close"
	RPCExec      RPCFunction = "Exec"
	RPCFileStat  RPCFunction = "FileStat"
)

type RPCResult

type RPCResult[T any] struct {
	UUID        string
	RPCFunction RPCFunction
	Result      T
	Error       string
}

type Server

type Server struct {
	Logger *slog.Logger
}

Jump to

Keyboard shortcuts

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