Skip to content

Commit

Permalink
Merge pull request #312 from vapor-ware/v1.2.0-staging
Browse files Browse the repository at this point in the history
V1.2.0 staging
  • Loading branch information
edaniszewski authored Oct 23, 2018
2 parents 79f6b2e + 1fc46d4 commit fc11f0f
Show file tree
Hide file tree
Showing 28 changed files with 1,699 additions and 52 deletions.
44 changes: 26 additions & 18 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

[[constraint]]
name = "github.com/Sirupsen/logrus"
version = "1.0.5"
version = "1.1.1"

[[constraint]]
name = "github.com/creasty/defaults"
Expand All @@ -39,15 +39,15 @@

[[constraint]]
name = "github.com/rs/xid"
version = "1.2.0"
version = "1.2.1"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.2"

[[constraint]]
name = "github.com/vapor-ware/synse-server-grpc"
branch = "master"
version = "1.1.0"

[[constraint]]
branch = "master"
Expand All @@ -59,7 +59,7 @@

[[constraint]]
name = "google.golang.org/grpc"
version = "1.12.2"
version = "1.15.0"

[[constraint]]
name = "gopkg.in/yaml.v2"
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ ifndef HAS_LINT
gometalinter --install
endif
@ # disable gotype: https://github.com/alecthomas/gometalinter/issues/40
gometalinter ./... \
gometalinter \
--disable=gotype --disable=interfacer \
--tests \
--vendor \
--sort=path --sort=line \
--aggregate \
--deadline=5m
--deadline=5m \
-e $$(go env GOROOT) \
./...

.PHONY: setup
setup: ## Install the build and development dependencies
Expand Down
2 changes: 2 additions & 0 deletions examples/listener/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plugin
device
31 changes: 31 additions & 0 deletions examples/listener/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Listener Plugin Example
#

PLUGIN_VERSION := 1.0

GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2> /dev/null || true)
GIT_TAG ?= $(shell git describe --tags 2> /dev/null || true)
BUILD_DATE := $(shell date -u +%Y-%m-%dT%T 2> /dev/null)
GO_VERSION := $(shell go version | awk '{ print $$3 }')

PKG_CTX := github.com/vapor-ware/synse-sdk/sdk
LDFLAGS := -w \
-X ${PKG_CTX}.BuildDate=${BUILD_DATE} \
-X ${PKG_CTX}.GitCommit=${GIT_COMMIT} \
-X ${PKG_CTX}.GitTag=${GIT_TAG} \
-X ${PKG_CTX}.GoVersion=${GO_VERSION} \
-X ${PKG_CTX}.PluginVersion=${PLUGIN_VERSION}


all: build pusher

build:
@go build -ldflags "${LDFLAGS}" -o plugin

pusher:
@go build -o device ./pusher/...


.PHONY: all build pusher
.DEFAULT_GOAL := all
84 changes: 84 additions & 0 deletions examples/listener/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
### Listener Plugin

This directory contains an example of a simple plugin that defines a listener
function in its device handler. Generally, a device that uses a listener is one
that generates push-based data for the plugin to collect. The listener will
listen for this data and update the plugin state accordingly.

In this case, there is only one kind of device, a "pusher". It will push random
data. In order to collect pushed data, we need something to actually push that
data. A simple program is defined in the "pusher" directory which can be run
alongside this plugin to provide the data. See the next section on how to build
and run the plugin and the pusher data source.

#### Usage

To build the pusher data source program, simply
```bash
make pusher
```
from within this directory. The plugin binary can be built with
```bash
make build
```

Both binaries will be output to the 'listener' directory and should
be named `device` and `plugin`, respectively. You can run both simultaneously
in separate shell instances (order doesn't matter):

**Shell 1**
```console
$ ./device
2018/10/12 11:03:15 Sending data on: :8553
2018/10/12 11:03:15 << 2596996162
2018/10/12 11:03:18 << 4039455774
2018/10/12 11:03:21 << 2854263694
2018/10/12 11:03:24 << 1879968118
2018/10/12 11:03:27 << 1823804162
2018/10/12 11:03:30 << 2949882636
2018/10/12 11:03:33 << 281908850
```

**Shell 2**
```console
./plugin
DEBU[0000] [sdk] adding 1 devices from config
DEBU[0000] [sdk] executing 0 pre-run action(s)
DEBU[0000] [sdk] executing 0 device setup action(s)
INFO[0000] Plugin Info:
INFO[0000] Tag: vaporio/listener-plugin
INFO[0000] Name: listener plugin
INFO[0000] Maintainer: vaporio
INFO[0000] Description: An example plugin with listener device
INFO[0000] VCS:
INFO[0000] Version Info:
INFO[0000] Plugin Version: 1.0
INFO[0000] SDK Version: 1.1.0
INFO[0000] Git Commit: 95a2def
INFO[0000] Git Tag: 1.1.0
INFO[0000] Build Date: 2018-10-12T15:01:46
INFO[0000] Go Version: go1.10.2
INFO[0000] OS/Arch: darwin/amd64
INFO[0000] Registered Devices:
INFO[0000] rack-1-board-1-f9def8b577bf354577e7c0c907fc5b86 (pusher)
INFO[0000] --------------------------------
DEBU[0000] [sdk] starting plugin run
DEBU[0000] [sdk] registering default health checks
DEBU[0000] [health] new periodic health check interval=30s name="read buffer health"
DEBU[0000] [health] new periodic health check interval=30s name="write buffer health"
DEBU[0000] [data manager] setting up data manager state
INFO[0000] [data manager] setting up listeners handler=pusher
INFO[0000] [data manager] starting read goroutine (reads enabled) mode=serial
INFO[0000] [data manager] starting write goroutine (writes enabled) mode=serial
INFO[0000] [data manager] running
DEBU[0000] [grpc] setting up server mode=unix
DEBU[0000] [server] configuring grpc server for insecure transport
INFO[0000] [grpc] listening on unix:/tmp/synse/procs/example-plugin.sock
INFO[0000] [data manager] running listener device=f9def8b577bf354577e7c0c907fc5b86 handler=pusher
[listener] got data: 2854263694
[listener] got data: 1879968118
[listener] got data: 1823804162
[listener] got data: 2949882636
[listener] got data: 281908850
```

5 changes: 5 additions & 0 deletions examples/listener/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1.2 # listeners added in cfg version 1.2
debug: true
network:
type: unix
address: example-plugin.sock
18 changes: 18 additions & 0 deletions examples/listener/config/device/pusher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 1.0
locations:
- name: r1b1
rack:
name: rack-1
board:
name: board-1
devices:
- name: pusher
metadata:
model: test-device
outputs:
- type: push_data
instances:
- info: Test Pusher Device
location: r1b1
data:
address: "localhost:8553"
Loading

0 comments on commit fc11f0f

Please sign in to comment.