encoder

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2019 License: Apache-2.0 Imports: 15 Imported by: 9

README

twirp-encoder-go

This repository contains autogenerated go Twirp stubs for the DECODE encoder component. These stubs have been generated automatically from the shared protobuf repo: https://github.com/thingful/decode-protorepo so these files should not be edited directly.

Making Changes

To make changes to the stubs, you must update the master protobuf definitions, regenerate the client stubs and push the updated versions to the appropriate repository. A script has been created within the master protorepo to automate this process.

Documentation

Overview

Package encoder is a generated twirp stub package. This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.5.0.

It is generated from these files:

encoder.proto

Index

Constants

View Source
const EncoderPathPrefix = "/twirp/decode.iot.encoder.Encoder/"

EncoderPathPrefix is used for all URL paths on a twirp Encoder server. Requests are always: POST EncoderPathPrefix/method It can be used in an HTTP mux to route twirp requests along with non-twirp requests on other routes.

Variables

View Source
var CreateStreamRequest_Exposure_name = map[int32]string{
	0: "UNKNOWN",
	1: "INDOOR",
	2: "OUTDOOR",
}
View Source
var CreateStreamRequest_Exposure_value = map[string]int32{
	"UNKNOWN": 0,
	"INDOOR":  1,
	"OUTDOOR": 2,
}
View Source
var CreateStreamRequest_Operation_Action_name = map[int32]string{
	0: "UNKNOWN",
	1: "SHARE",
	2: "BIN",
	3: "MOVING_AVG",
}
View Source
var CreateStreamRequest_Operation_Action_value = map[string]int32{
	"UNKNOWN":    0,
	"SHARE":      1,
	"BIN":        2,
	"MOVING_AVG": 3,
}

Functions

func WriteError

func WriteError(resp http.ResponseWriter, err error)

WriteError writes an HTTP response with a valid Twirp error format. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)

Types

type CreateStreamRequest

type CreateStreamRequest struct {
	// The token that uniquely identifies the device. This is a required field.
	DeviceToken string `protobuf:"bytes,1,opt,name=device_token,json=deviceToken,proto3" json:"device_token,omitempty"`
	// A name chosen by the user that they have assigned to their device
	DeviceLabel string `protobuf:"bytes,9,opt,name=device_label,json=deviceLabel,proto3" json:"device_label,omitempty"`
	// A unique identifier for the specific community represented by the policy
	// being applied.
	CommunityId string `protobuf:"bytes,8,opt,name=community_id,json=communityId,proto3" json:"community_id,omitempty"`
	// The public key of the recipient, again this is used in order to encrypt
	// outgoing data, as well as being used to signify to the datastore the bucket
	// in which data should be stored. This is a required field.
	RecipientPublicKey string `protobuf:"bytes,3,opt,name=recipient_public_key,json=recipientPublicKey,proto3" json:"recipient_public_key,omitempty"`
	// The location of the device to be claimed.
	Location *CreateStreamRequest_Location `protobuf:"bytes,5,opt,name=location,proto3" json:"location,omitempty"`
	// The specific exposure of the device, i.e. is this instance indoors or
	// outdoors.
	Exposure CreateStreamRequest_Exposure `protobuf:"varint,6,opt,name=exposure,proto3,enum=decode.iot.encoder.CreateStreamRequest_Exposure" json:"exposure,omitempty"`
	// The entitlements field holds a repeated list of Operations which each
	// define a transformational function for a specific sensor id. If no
	// operations are submitted, we currently create a stream that writes
	// through all received channels without applying any processing
	// transformations to the data, but if this field contains any elements, the
	// resulting stream will only contain the specified sensor type.
	Operations           []*CreateStreamRequest_Operation `protobuf:"bytes,7,rep,name=operations,proto3" json:"operations,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                         `json:"-"`
	XXX_unrecognized     []byte                           `json:"-"`
	XXX_sizecache        int32                            `json:"-"`
}

CreateStreamRequest is the message sent in order to create a new encoded stream. As a result of this method call, the stream encoder will have configured a stream that receives messages, applies all defined entitlement operations, then encrypts the data and sends it on to the configured datastore.

func (*CreateStreamRequest) Descriptor

func (*CreateStreamRequest) Descriptor() ([]byte, []int)

func (*CreateStreamRequest) GetCommunityId added in v0.1.0

func (m *CreateStreamRequest) GetCommunityId() string

func (*CreateStreamRequest) GetDeviceLabel added in v0.2.0

func (m *CreateStreamRequest) GetDeviceLabel() string

func (*CreateStreamRequest) GetDeviceToken added in v0.0.3

func (m *CreateStreamRequest) GetDeviceToken() string

func (*CreateStreamRequest) GetExposure added in v0.0.2

func (*CreateStreamRequest) GetLocation

func (*CreateStreamRequest) GetOperations added in v0.0.3

func (m *CreateStreamRequest) GetOperations() []*CreateStreamRequest_Operation

func (*CreateStreamRequest) GetRecipientPublicKey

func (m *CreateStreamRequest) GetRecipientPublicKey() string

func (*CreateStreamRequest) ProtoMessage

func (*CreateStreamRequest) ProtoMessage()

func (*CreateStreamRequest) Reset

func (m *CreateStreamRequest) Reset()

func (*CreateStreamRequest) String

func (m *CreateStreamRequest) String() string

func (*CreateStreamRequest) XXX_DiscardUnknown added in v0.0.3

func (m *CreateStreamRequest) XXX_DiscardUnknown()

func (*CreateStreamRequest) XXX_Marshal added in v0.0.3

func (m *CreateStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateStreamRequest) XXX_Merge added in v0.0.3

func (dst *CreateStreamRequest) XXX_Merge(src proto.Message)

func (*CreateStreamRequest) XXX_Size added in v0.0.3

func (m *CreateStreamRequest) XXX_Size() int

func (*CreateStreamRequest) XXX_Unmarshal added in v0.0.3

func (m *CreateStreamRequest) XXX_Unmarshal(b []byte) error

type CreateStreamRequest_Exposure added in v0.0.2

type CreateStreamRequest_Exposure int32

An enumeration which allows us to express whether the device will be located indoors or outdoors when deployed.

const (
	CreateStreamRequest_UNKNOWN CreateStreamRequest_Exposure = 0
	CreateStreamRequest_INDOOR  CreateStreamRequest_Exposure = 1
	CreateStreamRequest_OUTDOOR CreateStreamRequest_Exposure = 2
)

func (CreateStreamRequest_Exposure) EnumDescriptor added in v0.0.2

func (CreateStreamRequest_Exposure) EnumDescriptor() ([]byte, []int)

func (CreateStreamRequest_Exposure) String added in v0.0.2

type CreateStreamRequest_Location

type CreateStreamRequest_Location struct {
	// The longitude expressed as a decimal.
	Longitude float64 `protobuf:"fixed64,1,opt,name=longitude,proto3" json:"longitude,omitempty"`
	// The latitude expressed as a decimal.
	Latitude             float64  `protobuf:"fixed64,2,opt,name=latitude,proto3" json:"latitude,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A nested type capturing the location of the device expressed via decimal long/lat pair.

func (*CreateStreamRequest_Location) Descriptor

func (*CreateStreamRequest_Location) Descriptor() ([]byte, []int)

func (*CreateStreamRequest_Location) GetLatitude

func (m *CreateStreamRequest_Location) GetLatitude() float64

func (*CreateStreamRequest_Location) GetLongitude

func (m *CreateStreamRequest_Location) GetLongitude() float64

func (*CreateStreamRequest_Location) ProtoMessage

func (*CreateStreamRequest_Location) ProtoMessage()

func (*CreateStreamRequest_Location) Reset

func (m *CreateStreamRequest_Location) Reset()

func (*CreateStreamRequest_Location) String

func (*CreateStreamRequest_Location) XXX_DiscardUnknown added in v0.0.3

func (m *CreateStreamRequest_Location) XXX_DiscardUnknown()

func (*CreateStreamRequest_Location) XXX_Marshal added in v0.0.3

func (m *CreateStreamRequest_Location) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateStreamRequest_Location) XXX_Merge added in v0.0.3

func (dst *CreateStreamRequest_Location) XXX_Merge(src proto.Message)

func (*CreateStreamRequest_Location) XXX_Size added in v0.0.3

func (m *CreateStreamRequest_Location) XXX_Size() int

func (*CreateStreamRequest_Location) XXX_Unmarshal added in v0.0.3

func (m *CreateStreamRequest_Location) XXX_Unmarshal(b []byte) error

type CreateStreamRequest_Operation added in v0.0.3

type CreateStreamRequest_Operation struct {
	// The unique id of the sensor type for which this specific configuration is
	// defined. This is a required field.
	SensorId uint32 `protobuf:"varint,1,opt,name=sensor_id,json=sensorId,proto3" json:"sensor_id,omitempty"`
	// The specific action this entitlement defines for the sensor type. This is
	// a required field.
	Action CreateStreamRequest_Operation_Action `` /* 127-byte string literal not displayed */
	// The bins attribute is used to specify the the bins into which incoming
	// values should be classified. Each element in the list is the upper
	// inclusive bound of a bin. The values submitted must be sorted in strictly
	// increasing order. There is no need to add a highest bin with +Inf bound,
	// it will be added implicitly. This field is optional unless an Action of
	// `BIN` has been requested, in which case it is required. It is an error to
	// send values for this attribute unless the value of Action is `BIN`.
	Bins []float64 `protobuf:"fixed64,3,rep,packed,name=bins,proto3" json:"bins,omitempty"`
	// This attribute is used to control the entitlement in the case for which
	// we have specified an action type representing a moving average. It
	// represents the interval in seconds over which the moving average should
	// be calculated, e.g. for a 15 minute moving average the value supplied
	// here would be 900. This field is optional unless an Action of
	// `MOVING_AVG` has been specified, in which case it is required. It is an
	// error to send a value for this attribute unless the value of Action is
	// `MOVING_AVG`.
	Interval             uint32   `protobuf:"varint,4,opt,name=interval,proto3" json:"interval,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A nested type which is used to capture a list of specific operations we perform the stream.

func (*CreateStreamRequest_Operation) Descriptor added in v0.0.3

func (*CreateStreamRequest_Operation) Descriptor() ([]byte, []int)

func (*CreateStreamRequest_Operation) GetAction added in v0.0.3

func (*CreateStreamRequest_Operation) GetBins added in v0.0.3

func (m *CreateStreamRequest_Operation) GetBins() []float64

func (*CreateStreamRequest_Operation) GetInterval added in v0.0.3

func (m *CreateStreamRequest_Operation) GetInterval() uint32

func (*CreateStreamRequest_Operation) GetSensorId added in v0.0.3

func (m *CreateStreamRequest_Operation) GetSensorId() uint32

func (*CreateStreamRequest_Operation) ProtoMessage added in v0.0.3

func (*CreateStreamRequest_Operation) ProtoMessage()

func (*CreateStreamRequest_Operation) Reset added in v0.0.3

func (m *CreateStreamRequest_Operation) Reset()

func (*CreateStreamRequest_Operation) String added in v0.0.3

func (*CreateStreamRequest_Operation) XXX_DiscardUnknown added in v0.0.3

func (m *CreateStreamRequest_Operation) XXX_DiscardUnknown()

func (*CreateStreamRequest_Operation) XXX_Marshal added in v0.0.3

func (m *CreateStreamRequest_Operation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateStreamRequest_Operation) XXX_Merge added in v0.0.3

func (dst *CreateStreamRequest_Operation) XXX_Merge(src proto.Message)

func (*CreateStreamRequest_Operation) XXX_Size added in v0.0.3

func (m *CreateStreamRequest_Operation) XXX_Size() int

func (*CreateStreamRequest_Operation) XXX_Unmarshal added in v0.0.3

func (m *CreateStreamRequest_Operation) XXX_Unmarshal(b []byte) error

type CreateStreamRequest_Operation_Action added in v0.0.3

type CreateStreamRequest_Operation_Action int32

An enumeration which allows us to specify what type of sharing is to be defined for the specified sensor type. The default value is `SHARE` which implies sharing the data at full resolution. If this type is specified, it is an error if either of `buckets` or `interval` is also supplied.

const (
	CreateStreamRequest_Operation_UNKNOWN    CreateStreamRequest_Operation_Action = 0
	CreateStreamRequest_Operation_SHARE      CreateStreamRequest_Operation_Action = 1
	CreateStreamRequest_Operation_BIN        CreateStreamRequest_Operation_Action = 2
	CreateStreamRequest_Operation_MOVING_AVG CreateStreamRequest_Operation_Action = 3
)

func (CreateStreamRequest_Operation_Action) EnumDescriptor added in v0.0.3

func (CreateStreamRequest_Operation_Action) EnumDescriptor() ([]byte, []int)

func (CreateStreamRequest_Operation_Action) String added in v0.0.3

type CreateStreamResponse

type CreateStreamResponse struct {
	// An identifier for the stream which can be used in order to delete a stream
	// when required.
	StreamUid string `protobuf:"bytes,1,opt,name=stream_uid,json=streamUid,proto3" json:"stream_uid,omitempty"`
	// A secret token passed back to the caller which it must keep secret, in
	// order to be permitted to delete the stream.
	Token                string   `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

CreateStreamResponse is the message returned from the stream encoder after it successfully creates a stream. The device registration service should keep a record of this value so that it is able to delete the stream if required.

func (*CreateStreamResponse) Descriptor

func (*CreateStreamResponse) Descriptor() ([]byte, []int)

func (*CreateStreamResponse) GetStreamUid

func (m *CreateStreamResponse) GetStreamUid() string

func (*CreateStreamResponse) GetToken added in v0.0.3

func (m *CreateStreamResponse) GetToken() string

func (*CreateStreamResponse) ProtoMessage

func (*CreateStreamResponse) ProtoMessage()

func (*CreateStreamResponse) Reset

func (m *CreateStreamResponse) Reset()

func (*CreateStreamResponse) String

func (m *CreateStreamResponse) String() string

func (*CreateStreamResponse) XXX_DiscardUnknown added in v0.0.3

func (m *CreateStreamResponse) XXX_DiscardUnknown()

func (*CreateStreamResponse) XXX_Marshal added in v0.0.3

func (m *CreateStreamResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateStreamResponse) XXX_Merge added in v0.0.3

func (dst *CreateStreamResponse) XXX_Merge(src proto.Message)

func (*CreateStreamResponse) XXX_Size added in v0.0.3

func (m *CreateStreamResponse) XXX_Size() int

func (*CreateStreamResponse) XXX_Unmarshal added in v0.0.3

func (m *CreateStreamResponse) XXX_Unmarshal(b []byte) error

type DeleteStreamRequest

type DeleteStreamRequest struct {
	// The identifier for the stream to be deleted. This is a required field.
	StreamUid string `protobuf:"bytes,1,opt,name=stream_uid,json=streamUid,proto3" json:"stream_uid,omitempty"`
	// The secret token that was returned to the caller when creating the stream.
	// This is a required field, and must match the value stored internally for
	// the stream.
	Token                string   `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

DeleteStreamRequest is the message sent to the encoder in order to delete a configured stream. Sending this message must delete the MQTT subscription, as well as deleting all encryption credentials stored on the encoder.

func (*DeleteStreamRequest) Descriptor

func (*DeleteStreamRequest) Descriptor() ([]byte, []int)

func (*DeleteStreamRequest) GetStreamUid

func (m *DeleteStreamRequest) GetStreamUid() string

func (*DeleteStreamRequest) GetToken added in v0.0.3

func (m *DeleteStreamRequest) GetToken() string

func (*DeleteStreamRequest) ProtoMessage

func (*DeleteStreamRequest) ProtoMessage()

func (*DeleteStreamRequest) Reset

func (m *DeleteStreamRequest) Reset()

func (*DeleteStreamRequest) String

func (m *DeleteStreamRequest) String() string

func (*DeleteStreamRequest) XXX_DiscardUnknown added in v0.0.3

func (m *DeleteStreamRequest) XXX_DiscardUnknown()

func (*DeleteStreamRequest) XXX_Marshal added in v0.0.3

func (m *DeleteStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DeleteStreamRequest) XXX_Merge added in v0.0.3

func (dst *DeleteStreamRequest) XXX_Merge(src proto.Message)

func (*DeleteStreamRequest) XXX_Size added in v0.0.3

func (m *DeleteStreamRequest) XXX_Size() int

func (*DeleteStreamRequest) XXX_Unmarshal added in v0.0.3

func (m *DeleteStreamRequest) XXX_Unmarshal(b []byte) error

type DeleteStreamResponse

type DeleteStreamResponse struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

DeleteStreamResponse is a placeholder response message on a successful deletion of stream on the encoder.

func (*DeleteStreamResponse) Descriptor

func (*DeleteStreamResponse) Descriptor() ([]byte, []int)

func (*DeleteStreamResponse) ProtoMessage

func (*DeleteStreamResponse) ProtoMessage()

func (*DeleteStreamResponse) Reset

func (m *DeleteStreamResponse) Reset()

func (*DeleteStreamResponse) String

func (m *DeleteStreamResponse) String() string

func (*DeleteStreamResponse) XXX_DiscardUnknown added in v0.0.3

func (m *DeleteStreamResponse) XXX_DiscardUnknown()

func (*DeleteStreamResponse) XXX_Marshal added in v0.0.3

func (m *DeleteStreamResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DeleteStreamResponse) XXX_Merge added in v0.0.3

func (dst *DeleteStreamResponse) XXX_Merge(src proto.Message)

func (*DeleteStreamResponse) XXX_Size added in v0.0.3

func (m *DeleteStreamResponse) XXX_Size() int

func (*DeleteStreamResponse) XXX_Unmarshal added in v0.0.3

func (m *DeleteStreamResponse) XXX_Unmarshal(b []byte) error

type Encoder

type Encoder interface {
	// CreateStream sets up a new encoded stream for the encoder. Here we
	// subscribe to the specified MQTT topic, save the encryption keys, and start
	// listening for events. On receiving incoming messages via the MQTT broker,
	// we encrypt the contents using Zenroom and then write the encrypted data to
	// the configured datastore.
	CreateStream(context.Context, *CreateStreamRequest) (*CreateStreamResponse, error)

	// DeleteStream is called to remove the configuration for an encoded data
	// stream. This means deleting the MQTT subscription and removing all saved
	// credentials.
	DeleteStream(context.Context, *DeleteStreamRequest) (*DeleteStreamResponse, error)
}

Encoder is the basic interface proposed for the stream encoder component for DECODE. It currently just exposes two methods which allow for encoded streams to be created and destroyed. Creating a stream means setting up a subscription to an MQTT broker such that we start receiving events for a specific device. These events are then encrypted using the supplied credentials, and then written upstream to our encrypted datastore. Once a stream has been created it continues running indefinitely until receiving a call to delete the stream.

Later iterations of this service will implement filtering and aggregation operations on the stream, but for now all data is simply passed through to the datastore.

func NewEncoderJSONClient

func NewEncoderJSONClient(addr string, client HTTPClient) Encoder

NewEncoderJSONClient creates a JSON client that implements the Encoder interface. It communicates using JSON and can be configured with a custom HTTPClient.

func NewEncoderProtobufClient

func NewEncoderProtobufClient(addr string, client HTTPClient) Encoder

NewEncoderProtobufClient creates a Protobuf client that implements the Encoder interface. It communicates using Protobuf and can be configured with a custom HTTPClient.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.

type TwirpServer

type TwirpServer interface {
	http.Handler
	// ServiceDescriptor returns gzipped bytes describing the .proto file that
	// this service was generated from. Once unzipped, the bytes can be
	// unmarshalled as a
	// github.com/golang/protobuf/protoc-gen-go/descriptor.FileDescriptorProto.
	//
	// The returned integer is the index of this particular service within that
	// FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a
	// low-level field, expected to be used for reflection.
	ServiceDescriptor() ([]byte, int)
	// ProtocGenTwirpVersion is the semantic version string of the version of
	// twirp used to generate this file.
	ProtocGenTwirpVersion() string
}

TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.

func NewEncoderServer

func NewEncoderServer(svc Encoder, hooks *twirp.ServerHooks) TwirpServer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL