[go: nahoru, domu]

Skip to content

spr-networks/sprbus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sprbus

version Go Report Card

This package is a pubsub service using moby pubsub with support for unix sockets and grpc.

Command line tools

The client code in cmd/ can be used to connect to a remote spr api using websockets, or a local unix socket.

sprbus

See cmd/main.go

cd cmd/; make
./sprbus --help

remote

export 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"}'

sprbus intro example showing how to publish events.

Development

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

Thank you

The command line tool is built using BubbleTea, an awesome TUI Framework.