Documentation
¶
Overview ¶
Package daemon holds a datavase session for a terminal that comes and goes.
It does not know what it is serving. A Session is three methods — set a screen, run, stop — which is all a terminal interface needs to expose and deliberately less than tview or internal/ui. That keeps this package testable against a stand-in, and keeps the interface free of any notion that it might be running headless.
It does not know about sockets either: Serve takes an io.ReadWriteCloser, so net.Pipe exercises the whole exchange.
Index ¶
- Variables
- func APISocketPath() (string, error)
- func Dial(path string) (net.Conn, error)
- func Listen(path string) (net.Listener, error)
- func LogPath() (string, error)
- func ServeAPI(ln net.Listener, src snapshot.Source)
- func SocketPath() (string, error)
- type Options
- type Server
- type Session
- type State
- type Stateful
- type Switcher
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRunning = errors.New("a dv server is already listening")
ErrAlreadyRunning reports that something answered on the socket already.
Functions ¶
func APISocketPath ¶
APISocketPath is where the observation socket lives.
A second socket rather than a second message on the first one: the client protocol is private, binary and high-frequency, and this is public, textual and rare. One socket carrying both would make each worse, and only this one may have several readers at a time.
func LogPath ¶
LogPath is where a spawned server writes what it could not say to anyone.
A server that dies while starting has no client to tell, and without this the failure is invisible.
func ServeAPI ¶
ServeAPI answers snapshot requests until the listener closes.
One response per connection: there is one question, and a connection that asked it has nothing more to say. Readers are unlimited because none of them can change anything.
func SocketPath ¶
SocketPath is where a client looks for a server.
Beside the schema cache and the query history rather than beside the configuration file: this is runtime state, and it means nothing once the process behind it is gone.
Types ¶
type Options ¶
type Options struct {
// Version is what a client must match exactly.
Version string
// BuildFingerprint is version.BuildFingerprint(): empty outside a
// development build. It is compared only when both this and the client's
// Hello.BuildFingerprint are non-empty, so a release server — which never
// sets this — is never refused over it.
BuildFingerprint string
// Start builds the session the first client asked for, returning it and
// anything the user should be told about how it was built — a schema
// cache that would not open, a worktree that no longer exists. Those
// would otherwise land in a log nobody reads.
//
// The context bounds building only, not the session that comes out of
// it: whatever Start opens must outlive the call and is owned by the
// returned Session from then on.
Start func(context.Context, proto.Hello) (Session, []string, error)
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds one session and at most one client.
func (*Server) Detach ¶
func (s *Server) Detach()
Detach drops the current client and keeps the session.
func (*Server) Info ¶
Info is the tier of a snapshot that comes from this process. It cannot fail, which is what lets dv status answer whatever the session is doing.
func (*Server) Serve ¶
func (s *Server) Serve(rwc io.ReadWriteCloser)
Serve runs one client to completion and returns when it goes away.
type State ¶
State is what a second client needs to know before it may take the session somewhere else.