This package is a pubsub service using moby pubsub with support for unix sockets and grpc.
The client code in cmd/
can be used to connect to a remote spr api using websockets, or a local unix socket.
See cmd/main.go
cd cmd/; make
./sprbus --help
remote
export SPR_API_TOKEN="SPR-API-TOKEN"
./sprbus --addr 192.168.2.1
local
./sprbus
example topics
#www and api logs
./sprbus -t log
# device and wifi events
./sprbus -t device,wifi
#network traffic
./sprbus -t nft
network traffic in json, no timeout and pipe to jq
./sprbus -t nft -j --timeout 0 | jq .
publish test event
./sprbus -t test:event -p '{"msg": "testevent1234"}'
example showing how to publish events.
See example/main.go
using default sprbus:
//publish json string
sprbus.PublishString("wifi:station:event", "{\"json\": \"data\"}")
//publish object
sprbus.Publish("www:auth:user:fail", map[string]string{"username": username})
//subscribe
go sprbus.HandleEvent("wifi", func (topic string, json string) {
fmt.Println("wifi event", topic, json)
})
Custom unix socket server and client
See example/main.go for code to setup a custom unix socket server and client
The command line tool is built using BubbleTea, an awesome TUI Framework.