daemon

package
v0.0.0-...-b77b3d7 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2018 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package daemon implements a service for mediating access to the data store, and its client.

Most RPCs exposed by the service correspond to the methods of Store in the store package and are not documented here.

Index

Constants

View Source
const (
	// ServiceName is the name of the RPC service exposed by the daemon.
	ServiceName = "Daemon"

	// Version is the API version. It should be bumped any time the API changes.
	Version = -97
)

Variables

View Source
var (
	// ErrClientNotInitialized is returned when the Client is not initialized.
	ErrClientNotInitialized = errors.New("client not initialized")
	// ErrDaemonUnreachable is returned when the daemon cannot be reached after
	// several retries.
	ErrDaemonUnreachable = errors.New("daemon offline")
)

Functions

func Serve

func Serve(sockpath, dbpath string)

Serve runs the daemon service, listening on the socket specified by sockpath and serving data from dbpath. It quits upon receiving SIGTERM, SIGINT or when all active clients have disconnected.

Types

type AddCmdRequest

type AddCmdRequest struct {
	Text string
}

type AddCmdResponse

type AddCmdResponse struct {
	Seq int
}

type AddDirRequest

type AddDirRequest struct {
	Dir       string
	IncFactor float64
}

type AddDirResponse

type AddDirResponse struct{}

type Client

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

Client is a client to the Elvish daemon. A nil *Client is safe to use.

func NewClient

func NewClient(sockPath string) *Client

NewClient creates a new Client instance that talks to the socket. Connection creation is deferred to the first request.

func (*Client) AddCmd

func (c *Client) AddCmd(text string) (int, error)

func (*Client) AddDir

func (c *Client) AddDir(dir string, incFactor float64) error

func (*Client) Close

func (c *Client) Close() error

Close waits for all outstanding requests to finish and close the connection. If the client is nil, it does nothing and returns nil.

func (*Client) Cmd

func (c *Client) Cmd(seq int) (string, error)

func (*Client) Cmds

func (c *Client) Cmds(from, upto int) ([]string, error)

func (*Client) DelSharedVar

func (c *Client) DelSharedVar(name string) error

func (*Client) Dirs

func (c *Client) Dirs(blacklist map[string]struct{}) ([]storedefs.Dir, error)

func (*Client) NextCmd

func (c *Client) NextCmd(from int, prefix string) (int, string, error)

func (*Client) NextCmdSeq

func (c *Client) NextCmdSeq() (int, error)

func (*Client) Pid

func (c *Client) Pid() (int, error)

func (*Client) PrevCmd

func (c *Client) PrevCmd(upto int, prefix string) (int, string, error)

func (*Client) ResetConn

func (c *Client) ResetConn() error

ResetConn resets the current connection. A new connection will be established the next time a request is made. If the client is nil, it does nothing.

func (*Client) SetSharedVar

func (c *Client) SetSharedVar(name, value string) error

func (*Client) SharedVar

func (c *Client) SharedVar(name string) (string, error)

func (*Client) SockPath

func (c *Client) SockPath() string

SockPath returns the socket path that the Client talks to. If the client is nil, it returns an empty string.

func (*Client) Version

func (c *Client) Version() (int, error)

type CmdRequest

type CmdRequest struct {
	Seq int
}

type CmdResponse

type CmdResponse struct {
	Text string
}

type CmdsRequest

type CmdsRequest struct {
	From int
	Upto int
}

type CmdsResponse

type CmdsResponse struct {
	Cmds []string
}

type DelSharedVarRequest

type DelSharedVarRequest struct {
	Name string
}

type DelSharedVarResponse

type DelSharedVarResponse struct{}

type DirsRequest

type DirsRequest struct {
	Blacklist map[string]struct{}
}

type DirsResponse

type DirsResponse struct {
	Dirs []storedefs.Dir
}

type NextCmdRequest

type NextCmdRequest struct {
	From   int
	Prefix string
}

type NextCmdResponse

type NextCmdResponse struct {
	Seq  int
	Text string
}

type NextCmdSeqRequest

type NextCmdSeqRequest struct{}

type NextCmdSeqResponse

type NextCmdSeqResponse struct {
	Seq int
}

type PidRequest

type PidRequest struct{}

type PidResponse

type PidResponse struct {
	Pid int
}

type PrevCmdRequest

type PrevCmdRequest struct {
	Upto   int
	Prefix string
}

type PrevCmdResponse

type PrevCmdResponse struct {
	Seq  int
	Text string
}

type Service

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

Service provides the daemon RPC service. It is suitable as a service for net/rpc.

func (*Service) AddCmd

func (s *Service) AddCmd(req *AddCmdRequest, res *AddCmdResponse) error

func (*Service) AddDir

func (s *Service) AddDir(req *AddDirRequest, res *AddDirResponse) error

func (*Service) Cmd

func (s *Service) Cmd(req *CmdRequest, res *CmdResponse) error

func (*Service) Cmds

func (s *Service) Cmds(req *CmdsRequest, res *CmdsResponse) error

func (*Service) DelSharedVar

func (s *Service) DelSharedVar(req *DelSharedVarRequest, res *DelSharedVarResponse) error

func (*Service) Dirs

func (s *Service) Dirs(req *DirsRequest, res *DirsResponse) error

func (*Service) NextCmd

func (s *Service) NextCmd(req *NextCmdRequest, res *NextCmdResponse) error

func (*Service) NextCmdSeq

func (s *Service) NextCmdSeq(req *NextCmdSeqRequest, res *NextCmdSeqResponse) error

func (*Service) Pid

func (s *Service) Pid(req *PidRequest, res *PidResponse) error

Pid returns the process ID of the daemon.

func (*Service) PrevCmd

func (s *Service) PrevCmd(req *PrevCmdRequest, res *PrevCmdResponse) error

func (*Service) SetSharedVar

func (s *Service) SetSharedVar(req *SetSharedVarRequest, res *SetSharedVarResponse) error

func (*Service) SharedVar

func (s *Service) SharedVar(req *SharedVarRequest, res *SharedVarResponse) error

func (*Service) Version

func (s *Service) Version(req *VersionRequest, res *VersionResponse) error

Version returns the API version number.

type SetSharedVarRequest

type SetSharedVarRequest struct {
	Name  string
	Value string
}

type SetSharedVarResponse

type SetSharedVarResponse struct{}

type SharedVarRequest

type SharedVarRequest struct {
	Name string
}

type SharedVarResponse

type SharedVarResponse struct {
	Value string
}

type VersionRequest

type VersionRequest struct{}

type VersionResponse

type VersionResponse struct {
	Version int
}

Jump to

Keyboard shortcuts

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