github.com/simpleiot/simpleiot@v0.18.3/client/client.go (about) 1 package client 2 3 import ( 4 "github.com/nats-io/nats.go" 5 "github.com/simpleiot/simpleiot/data" 6 ) 7 8 // Client interface describes methods a Simple Iot client must implement. 9 // This is to be kept as simple as possible, and the ClientManager does all 10 // the heavy lifting of interacting with the rest of the SIOT system. 11 // Run should block until Stop is called. 12 // Run MUST return when Stop is called. 13 // Stop does not block -- wait until Run returns if you need to know the client 14 // is stopped. 15 // Points and EdgePoints are called when there are updates to the client node. 16 // The client Manager filters out all points with Origin set to "" because it 17 // assumes the point was generated by the client and the client already knows about it. 18 // Thus, if you want points to get to a client, Origin must be set. 19 type Client interface { 20 RunStop 21 22 Points(string, []data.Point) 23 EdgePoints(string, string, []data.Point) 24 } 25 26 // DefaultClients returns an actor for the default group of built in clients 27 func DefaultClients(nc *nats.Conn) (*RunGroup, error) { 28 g := NewRunGroup("Default clients") 29 30 sc := NewManager(nc, NewSerialDevClient, nil) 31 g.Add(sc) 32 33 cb := NewManager(nc, NewCanBusClient, nil) 34 g.Add(cb) 35 36 rc := NewManager(nc, NewRuleClient, nil) 37 g.Add(rc) 38 39 db := NewManager(nc, NewDbClient, nil) 40 g.Add(db) 41 42 sg := NewManager(nc, NewSignalGeneratorClient, nil) 43 g.Add(sg) 44 45 sync := NewManager(nc, NewSyncClient, nil) 46 g.Add(sync) 47 48 metrics := NewManager(nc, NewMetricsClient, nil) 49 g.Add(metrics) 50 51 particle := NewManager(nc, NewParticleClient, nil) 52 g.Add(particle) 53 54 shelly := NewManager(nc, NewShellyClient, nil) 55 g.Add(shelly) 56 57 shellyIO := NewManager(nc, NewShellyIOClient, []string{data.NodeTypeShelly}) 58 g.Add(shellyIO) 59 60 ntp := NewManager(nc, NewNTPClient, nil) 61 g.Add(ntp) 62 63 nm := NewManager(nc, NewNetworkManagerClient, nil) 64 g.Add(nm) 65 66 up := NewManager(nc, NewUpdateClient, nil) 67 g.Add(up) 68 69 fc := NewManager(nc, NewFileClient, []string{data.NodeTypeCanBus, data.NodeTypeSerialDev}) 70 g.Add(fc) 71 72 return g, nil 73 }