Documentation ¶
Overview ¶
Package server is a library used to build Altid servers
go get github.com/altid/server
9pd
Additionally, this contains the canonical server for Altid, 9pd. It can be retrieved with the following
go get github.com/altid/server/cmd/9pd
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner interface { // Run will be called internally once services have been iterated and set up // name will be the name of the service, and initial will be the default buffer // Client should be initialized `c.Client(0)` and set to `initial` Run(context.Context, *Service) error // Address must return the IP + Port pair the server uses, for use with mDNS broadcasts internally Address() (string, string) }
type Server ¶
type Server struct { // Logger can be set to log server messages // such as buffer activity or control message writes Logger func(string, ...interface{}) // contains filtered or unexported fields }
type Service ¶
type Service struct { // The client manager is expected to be used whenever a client connects to a server // generally a server only has to call "c := client.Client(0)" // This adds the client to the stack using the special ID of 0 // making sure to client.Remove(c.UUID) after you're done with it. // Clients will only receive events when they are registered! Client *client.Manager // Files holds the handlers to our internal file representations // The Normal and Stat methods return useful types // Generally, Normal returns an io.ReadWriter; but you should switch on all variants // Of io.Writer, io.Reader, io.ReaderAt, io.WriterAt, io.Seeker, and any combination therein // Additionally, if the file requested is a directory, a []*os.FileInfo will be returned instead // Stat will return an *os.FileInfo for a given file Files *files.Files Commands chan *command.Command // contains filtered or unexported fields }
Directories ¶
Path | Synopsis |
---|---|
Package client provides management of clients for a server go get github.com/altid/server/client
|
Package client provides management of clients for a server go get github.com/altid/server/client |
cmd
|
|
Package files is a layer over a normal directory to synthesize Stat responses, and allow special semantics for Read/Write requests to opened files Adding import ( "os" "path" "github.com/altid/server/files" ) type NormalHandler struct{} func NewNormal() *NormalHandler { return &NormalHandler{} } func (*NormalHandler) Normal(msg *files.Message) (interface{}, error) { fp := path.Join(msg.Service, msg.Buffer, msg.Target) return os.Open(fp) } func (*NormalHandler) Stat(msg *files.Message) (os.FileInfo, error) { fp := path.Join(msg.Service, msg.Buffer, msg.Target) return os.Lstat(fp) } func main() { fh := files.Handle("/path/to/dir") fh.Add("/myfile", NewNormal()) // [...] }
|
Package files is a layer over a normal directory to synthesize Stat responses, and allow special semantics for Read/Write requests to opened files Adding import ( "os" "path" "github.com/altid/server/files" ) type NormalHandler struct{} func NewNormal() *NormalHandler { return &NormalHandler{} } func (*NormalHandler) Normal(msg *files.Message) (interface{}, error) { fp := path.Join(msg.Service, msg.Buffer, msg.Target) return os.Open(fp) } func (*NormalHandler) Stat(msg *files.Message) (os.FileInfo, error) { fp := path.Join(msg.Service, msg.Buffer, msg.Target) return os.Lstat(fp) } func main() { fh := files.Handle("/path/to/dir") fh.Add("/myfile", NewNormal()) // [...] } |
internal
|
|
mdns
Package mdns is a convenience wrapper over github.com/grandcat/zeroconf for listing Altid services over mdns go get github.com/altid/server/mdns
|
Package mdns is a convenience wrapper over github.com/grandcat/zeroconf for listing Altid services over mdns go get github.com/altid/server/mdns |
tabs
Package tabs contains helper functions for managing tabs in Altid services go get github.com/altid/server/tabs
|
Package tabs contains helper functions for managing tabs in Altid services go get github.com/altid/server/tabs |
tail
Package tail mimicks the behaviour of `tail -f` tail watches an events file for writes and sends out matching events, one for each line written.
|
Package tail mimicks the behaviour of `tail -f` tail watches an events file for writes and sends out matching events, one for each line written. |
Click to show internal directories.
Click to hide internal directories.