Skip to content

vapor-ware/synse-client-go

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Build Status Godoc Go Report Card

Synse Client (Golang)

The official HTTP and WebSocket client for interacting with the Synse Server API, written in Go.

For details on the Synse Server API, see the API Documentation.

Installing

This package can be installed via go get

go get github.com/vapor-ware/synse-client-go

Using

Initializing

Both the HTTP and WebSocket client must be initialized with configuration options. These options identify the Synse Server instance to communicate with as well as set other connection-related capabilities (timeout, TLS, etc).

import "github.com/vapor-ware/synse-client-go/synse"

func main() {
	opts := &synse.Options{
		Address: "localhost",
	}

	client, err := NewHTTPClientV3(opts)
	// or client, err := NewWebSocketClientV3(opts)
}

API

The table below describes which API endpoint/event correspond with each client method.

Method HTTP endpoint WebSocket request
Status() /test request/status
Version() /version request/version
Config() /v3/config request/config
Plugins() /v3/plugin request/plugins
Plugin(string) /v3/plugin/{plugin_id} request/plugin
PluginHealth() /v3/plugin/health request/plugin_health
Scan(scheme.ScanOptions) /v3/scan request/scan
Tags(scheme.TagsOptions) /v3/tags request/tags
Info(string) /v3/info/{device_id} request/info
Read(scheme.ReadOptions) /v3/read request/read
ReadDevice(string, scheme.ReadOptions) /v3/read/{device_id} request/read_device
ReadCache(scheme.ReadCacheOptions) /v3/readcache request/read_cache
WriteAsync(string, []scheme.WriteData) /v3/write/{device_id} request/write_async
WriteSync(string, []scheme.WriteData) /v3/write/wait/{device_id} request/write_sync
Transactions() /v3/transaction request/transactions
Transaction(string) /v3/transaction/{transaction_id} request/transaction

Additionally, there are a few client methods which do not correspond to an API endpoint:

Method Description
GetOptions() Return the current config options of the client.
Open() Open the WebSocket connection between the client and Synse Server. WebSocket client only.
Close() Close the WebSocket connection between the client and Synse Server. WebSocket client only.

For more information about the response scheme, please refer to the documentation.

Developing

To provide a simple and uniform development flow, Makefile targets should be used for basic development actions. To lint and format the project source code:

make lint
make fmt

To run all unit tests:

make test

For a full accounting of available targets, see the Makefile or run make help.