Documentation
¶
Index ¶
- Constants
- func GetEnv(name string, defaultValue string) string
- func ThingRestore(t Thinger)
- func ThingStore(t Thinger)
- func ValidId(s string) bool
- type Bus
- type CompositeFS
- type Injector
- type Locker
- type Maker
- type Makers
- type Msg
- type Runner
- type Server
- func (s *Server) AdoptThing(thinger Thinger) error
- func (s *Server) CreateThing(id, model, name string) (Thinger, error)
- func (s *Server) DeleteThing(id string) error
- func (s *Server) Dial(url *url.URL, tries int) Socketer
- func (s *Server) Dials(durls string)
- func (s *Server) GetModels() []string
- func (s *Server) Handle(path string, handler http.Handler)
- func (s *Server) HandleFunc(path string, handler http.HandlerFunc)
- func (s *Server) MaxSockets(maxSockets int)
- func (s *Server) NewInjector(id string) *Injector
- func (s *Server) RegisterModel(model string, maker ThingMaker)
- func (s *Server) Run()
- func (s *Server) ServeTLS(host string) error
- func (s *Server) Unhandle(path string)
- func (s *Server) UnregisterModel(model string)
- type Socketer
- type Subscribers
- type Thing
- func (t *Thing) Announce() *Msg
- func (t *Thing) FailSafe()
- func (t *Thing) Identity() (string, string, string)
- func (t *Thing) IsMetal() bool
- func (t *Thing) IsOnline() bool
- func (t *Thing) Lock()
- func (t *Thing) Run(*Injector)
- func (t *Thing) SetFlag(flag uint32)
- func (t *Thing) SetOnline(online bool)
- func (t *Thing) Setup()
- func (t *Thing) String() string
- func (t *Thing) Subscribers() Subscribers
- func (t *Thing) TestFlag(flag uint32) bool
- func (t *Thing) Unlock()
- type ThingMaker
- type ThingMsg
- type ThingMsgAdopted
- type ThingMsgAnnounce
- type ThingMsgConnect
- type ThingMsgCreated
- type ThingMsgDeleted
- type ThingMsgDisconnect
- type Thinger
Constants ¶
const ( // Socket is broadcast-ready. If flag is not set, msgs will not be // broadcast on this socket. SocketFlagBcast uint32 = 1 << iota )
const ( // ThingFlagMetal indicates thing is running the Run() loop ThingFlagMetal uint32 = 1 << iota )
Variables ¶
This section is empty.
Functions ¶
func ThingRestore ¶
func ThingRestore(t Thinger)
func ThingStore ¶
func ThingStore(t Thinger)
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is a logical msg broadcast bus. Msgs arrive on sockets connected to the bus. A received msg can be broadcast to the other sockets, or replied back to sender. A socket has a tag, and the bus segregates the sockets by tag. Msgs arriving on a tagged socket will be broadcast only to other sockets with same tag. Think of a tag as a VLAN. The empty tag "" is the default tag on the bus.
func (*Bus) MaxSockets ¶
MaxSockets sets the maximum number of socket connections that can be made to the bus. Any socket connection attempts past the maximum will block until other sockets drop.
type CompositeFS ¶
type CompositeFS struct {
// contains filtered or unexported fields
}
CompositeFS is an ordered (layered) file system, built up from individual file systems
func NewCompositeFS ¶
func NewCompositeFS() *CompositeFS
func (*CompositeFS) AddFS ¶
func (c *CompositeFS) AddFS(fsys fs.ReadFileFS)
AddFS adds fsys to the composite fs. Order matters: first added is lowest in priority when searching for a file name in the composite fs.
func (*CompositeFS) Open ¶
func (c *CompositeFS) Open(name string) (fs.File, error)
Open a file by name
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
Injector is a one-way socket used for injecting msgs onto the bus. The msgs cannot be sent back (replied) on an injector socket.
func NewInjector ¶
type Msg ¶
type Msg struct {
// contains filtered or unexported fields
}
Msg is sent and received on a bus via a socket
func (*Msg) Broadcast ¶
Broadcast the msg to all other matching-tagged sockets on the bus. The source socket is excluded.
type Server ¶
Server serves a Thing
func (*Server) AdoptThing ¶
AdoptThing adds a thing to server
func (*Server) CreateThing ¶
CreateThing creates a new Thing based on model
func (*Server) DeleteThing ¶
DeleteThing deletes a Thing given id
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(path string, handler http.HandlerFunc)
HandleFunc registers an http handler func for path
func (*Server) MaxSockets ¶
MaxSocket sets the maximum number of sockets that can connect to the server
func (*Server) NewInjector ¶
func (*Server) RegisterModel ¶
func (s *Server) RegisterModel(model string, maker ThingMaker)
RegisterModel registers a new Thing model
func (*Server) UnregisterModel ¶
UnregisterModel unregisters the Thing model
type Socketer ¶
type Socketer interface { // Close the socket Close() // Send the msg on the socket Send(*Msg) error // Name of socket String() string // Tag returns the socket tag Tag() string // SetTag set the socket tag. A socket tag is like a VLAN ID. SetTag(string) // SetFlag on socket SetFlag(uint32) // TestFlag returns true if flag is set TestFlag(uint32) bool }
Socketer defines a socket interface
type Subscribers ¶
type Thing ¶
type Thing struct { Path string Id string Model string Name string Online bool // contains filtered or unexported fields }
Thing implements Thinger and is the base structure for building things
func (*Thing) Announce ¶
Announce returns an announcement msg. The announcement msg identifies the Thing.
func (*Thing) Subscribers ¶
func (t *Thing) Subscribers() Subscribers
type ThingMsg ¶
type ThingMsg struct {
Path string
}
ThingMsg is the prototypical msg. All msgs have the Path member.
type ThingMsgAdopted ¶
ThingMsgeAdopted is sent when as new Thing is adopted on a server
type ThingMsgAnnounce ¶
ThingMsgAnnounce is sent to annouce a Thing to a server
type ThingMsgConnect ¶
ThingMsgConnect is sent when a Thing connects to a server
type ThingMsgCreated ¶
ThingMsgCreated is sent when a new Thing is created on a server
type ThingMsgDeleted ¶
ThingMsgDeleted is sent when Thing is deleted from a server
type ThingMsgDisconnect ¶
ThingMsgDisconnect is sent when a Thing disconnects from a server