admin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package admin provides the admin RPC client and server. This currently is JSON-RPC over an abstract AF_UNIX socket, but that is temporary till a real API endpoint is provided over the web server.

Index

Constants

View Source
const (
	MethodDump  = "dump"
	MethodFlush = "flush"
	MethodStats = "stats"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an admin RPC client.

func NewClient

func NewClient(
	cfg *config.Config,
	logger *slog.Logger,
) (*Client, error)

NewClient initializes and connects to a RPC server.

func (*Client) Close

func (cli *Client) Close() error

Close closes the client.

func (*Client) Dump

func (cli *Client) Dump(ctx context.Context) (string, error)

Dump instructs the remote instance to write a dump of the DB.

func (*Client) Flush

func (cli *Client) Flush(ctx context.Context, params *FlushParams) error

Flush instructs the remote instance to flush parts of the DB.

func (*Client) Stats

func (cli *Client) Stats(ctx context.Context) (*db.Stats, error)

Stats queries the remote instance for statistics.

type FlushParams

type FlushParams struct {
	Pending bool `json:"pending,omitempty"`
	Alerts  bool `json:"alerts,omitempty"`
}

type Server

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

Server is an admin RPC server.

func NewServer

func NewServer(
	ctx context.Context,
	cfg *config.Config,
	db *db.DB,
	_ *xmr.Client,
	logger *slog.Logger,
) (*Server, error)

NewServer initializes and starts the admin RPC server.

func (*Server) Accept

func (srv *Server) Accept() (net.Conn, error)

func (*Server) Addr

func (srv *Server) Addr() net.Addr

func (*Server) Close

func (srv *Server) Close() error

func (*Server) Wait

func (srv *Server) Wait()

Jump to

Keyboard shortcuts

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