rpc

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 18 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 AnsibleExecuteArgs added in v0.0.6

type AnsibleExecuteArgs struct {
	Name               string
	Args               map[string]any
	Environment        map[string]string
	Check              bool
	DebugKeepTempFiles bool
}

type AnsibleExecuteResult added in v0.0.6

type AnsibleExecuteResult struct {
	Stderr       []byte
	Stdout       []byte
	ExitCode     int
	Success      bool
	Result       map[string]any
	DebugTempDir string
}

func AnsibleExecute added in v0.0.6

func AnsibleExecute(args AnsibleExecuteArgs) (AnsibleExecuteResult, 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      `json:",omitempty"`
	Size         *int64       `json:",omitempty"`
	FileMode     *fs.FileMode `json:",omitempty"`
	ModifiedTime *time.Time   `json:",omitempty"`

	// depends on FileInfo.Sys()
	AccessTime *time.Time `json:",omitempty"`
	CreateTime *time.Time `json:",omitempty"`
	Dev        *uint64    `json:",omitempty"`
	Gid        *uint64    `json:",omitempty"`
	GroupName  *string    `json:",omitempty"`
	Inode      *uint64    `json:",omitempty"`
	Nlink      *uint64    `json:",omitempty"`
	Uid        *uint64    `json:",omitempty"`
	UserName   *string    `json:",omitempty"`

	// conditional on CalculateChecksum
	SHA256Checksum *string `json:",omitempty"`
}

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"
	RPCAnsibleExecute RPCFunction = "AnsibleExecute"
	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