datastore

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2019 License: Apache-2.0 Imports: 16 Imported by: 15

README

twirp-datastore-go

This repository contains autogenerated go Twirp stubs for the DECODE datastore 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 datastore 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:

datastore.proto

Index

Constants

View Source
const DatastorePathPrefix = "/twirp/decode.iot.datastore.Datastore/"

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

Variables

This section is empty.

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 Datastore

type Datastore interface {
	// WriteData is our function call that writes a single encrypted data event to
	// the underlying storage substrate. It takes a WriteRequest containing the
	// actual data to be stored along with public key of the bucket for which data
	// should be persisted and the submitting user's DECODE user id. THese
	// additional attributes allow us to request the data from the bucket by
	// public key.
	WriteData(context.Context, *WriteRequest) (*WriteResponse, error)

	// ReadData is used to request data from the data store. Data is requested
	// keyed by the public key used to encrypt it (encoded as a Base64 or hex
	// string probably). In addition a read request allows the client to specify a
	// time interval so that data is only retrieved if it was recorded within the
	// interval. Pagination is supported to allow for large intervals to be
	// requested without having to return all the data in one hit.
	ReadData(context.Context, *ReadRequest) (*ReadResponse, error)
}

Datastore is the interface we propose exposing to implement an encrypted datastore for the IOT scale model and pilot for DECODE. We expose two API methods, one to write and one to read data.

func NewDatastoreJSONClient

func NewDatastoreJSONClient(addr string, client HTTPClient) Datastore

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

func NewDatastoreProtobufClient

func NewDatastoreProtobufClient(addr string, client HTTPClient) Datastore

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

type EncryptedEvent

type EncryptedEvent struct {
	// The time at which the event was recorded by the datastore.
	EventTime *timestamp.Timestamp `protobuf:"bytes,1,opt,name=event_time,json=eventTime,proto3" json:"event_time,omitempty"`
	// The opaque chunk of bytes comprising the encoded data from the device.
	Data                 []byte   `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

EncryptedEvent is a message representing a single instance of encrypted data that is stored by the datastore. When reading data we return lists of this type, which comprise a timestamp and a chunk of encoded data. From the datastore's perspective the encrypted data can be viewed as just an opaque chunk of bytes, however our encoding engine (Zenroom), does allow us to just encrypt the values within a JSON structure, but for the datastore's purposes we don't care about this.

func (*EncryptedEvent) Descriptor

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

func (*EncryptedEvent) GetData

func (m *EncryptedEvent) GetData() []byte

func (*EncryptedEvent) GetEventTime

func (m *EncryptedEvent) GetEventTime() *timestamp.Timestamp

func (*EncryptedEvent) ProtoMessage

func (*EncryptedEvent) ProtoMessage()

func (*EncryptedEvent) Reset

func (m *EncryptedEvent) Reset()

func (*EncryptedEvent) String

func (m *EncryptedEvent) String() string

func (*EncryptedEvent) XXX_DiscardUnknown added in v0.0.4

func (m *EncryptedEvent) XXX_DiscardUnknown()

func (*EncryptedEvent) XXX_Marshal added in v0.0.4

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

func (*EncryptedEvent) XXX_Merge added in v0.0.4

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

func (*EncryptedEvent) XXX_Size added in v0.0.4

func (m *EncryptedEvent) XXX_Size() int

func (*EncryptedEvent) XXX_Unmarshal added in v0.0.4

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

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 ReadRequest

type ReadRequest struct {
	// The start time represents the start of an interval for which we wish to
	// read data. It is an error for start_time to be in the future or to be
	// after end_time. This field is required.
	StartTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
	// The end time represents the end of an interval for which we wish to read
	// data. It may be nil, in which case it defaults to "now".
	EndTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
	// The page cursor is an opaque string that an implementing server can
	// understand in order to efficiently paginate through events.  The value
	// sent here cannot be calculated by the client, rather they should just
	// inspect value returned from a previous call to to `ReadData` and if this a
	// non-empty string, then this value can be sent back to the server to get
	// the "next" page of results.  This field is optional.
	PageCursor string `protobuf:"bytes,4,opt,name=page_cursor,json=pageCursor,proto3" json:"page_cursor,omitempty"`
	// The maximum number of encrypted events to return in the response. The
	// default value is 500. Returns an error if the caller requests a larger
	// page size than the maximum.
	PageSize uint32 `protobuf:"varint,5,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	// A string that uniquely identifies the community for which data is being
	// requested. A recipient will not be able to decrypt the data unless they
	// are in possession of the correct credentials. This is a required field.
	CommunityId          string   `protobuf:"bytes,7,opt,name=community_id,json=communityId,proto3" json:"community_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

ReadRequest is the message that is sent to the store in order to read data for a specific bucket. When requesting data a client must submit the public key and entitlement policy id which identify the bucket, then optional start and end timestamps. If the time attributes are included then the end time must be after the start time; if no end time is specified then the default is "now". It is an error to specify an end time without a start time.

func (*ReadRequest) Descriptor

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

func (*ReadRequest) GetCommunityId added in v0.1.1

func (m *ReadRequest) GetCommunityId() string

func (*ReadRequest) GetEndTime

func (m *ReadRequest) GetEndTime() *timestamp.Timestamp

func (*ReadRequest) GetPageCursor

func (m *ReadRequest) GetPageCursor() string

func (*ReadRequest) GetPageSize

func (m *ReadRequest) GetPageSize() uint32

func (*ReadRequest) GetStartTime

func (m *ReadRequest) GetStartTime() *timestamp.Timestamp

func (*ReadRequest) ProtoMessage

func (*ReadRequest) ProtoMessage()

func (*ReadRequest) Reset

func (m *ReadRequest) Reset()

func (*ReadRequest) String

func (m *ReadRequest) String() string

func (*ReadRequest) XXX_DiscardUnknown added in v0.0.4

func (m *ReadRequest) XXX_DiscardUnknown()

func (*ReadRequest) XXX_Marshal added in v0.0.4

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

func (*ReadRequest) XXX_Merge added in v0.0.4

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

func (*ReadRequest) XXX_Size added in v0.0.4

func (m *ReadRequest) XXX_Size() int

func (*ReadRequest) XXX_Unmarshal added in v0.0.4

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

type ReadResponse

type ReadResponse struct {
	// The list of encrypted events containing the actual data being requested.
	// This list will be returned in ascending time order, and each element
	// contains a timestamp as well as the actual chunk of encrypted data. If no
	// data is available this will be an empty list.
	Events []*EncryptedEvent `protobuf:"bytes,2,rep,name=events,proto3" json:"events,omitempty"`
	// An optional field containing a pointer to the next page of results
	// expressed as an opaque string. Clients should not expect to be able to
	// parse this string as its contents are strictly implementation specific and
	// subject to change at any time. Rather the value here should just be checked
	// to see if it is an empty string or contains a value, and if any value is
	// present, the client can pass it back in a new read request as the value of
	// the page_cursor field.
	NextPageCursor string `protobuf:"bytes,3,opt,name=next_page_cursor,json=nextPageCursor,proto3" json:"next_page_cursor,omitempty"`
	// The page size that was originally requested to create this response.
	// Supplied to make it easy for the client to construct a new request for the
	// next page.
	PageSize uint32 `protobuf:"varint,4,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	// A string that uniquely identifies the community for which data is being
	// sent. A recipient will not be able to decrypt the data unless they
	// are in possession of the correct credentials.
	CommunityId          string   `protobuf:"bytes,6,opt,name=community_id,json=communityId,proto3" json:"community_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

ReadResponse is the top level message returned by the read operations to the datastore. It contains the public key for the recipient, as well as the entitlement policy id. The events property contains a list of encrypted events in ascending time order. This will not necessarily be all possible events for the requested time period, as we have implemented pagination for this endpoint. If the response contains a non-empty string for the next_page_cursor property, then there are more pages of data to be consumed; if this property is the empty string, then the response is all data available for the requested time period.

func (*ReadResponse) Descriptor

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

func (*ReadResponse) GetCommunityId added in v0.1.1

func (m *ReadResponse) GetCommunityId() string

func (*ReadResponse) GetEvents

func (m *ReadResponse) GetEvents() []*EncryptedEvent

func (*ReadResponse) GetNextPageCursor

func (m *ReadResponse) GetNextPageCursor() string

func (*ReadResponse) GetPageSize

func (m *ReadResponse) GetPageSize() uint32

func (*ReadResponse) ProtoMessage

func (*ReadResponse) ProtoMessage()

func (*ReadResponse) Reset

func (m *ReadResponse) Reset()

func (*ReadResponse) String

func (m *ReadResponse) String() string

func (*ReadResponse) XXX_DiscardUnknown added in v0.0.4

func (m *ReadResponse) XXX_DiscardUnknown()

func (*ReadResponse) XXX_Marshal added in v0.0.4

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

func (*ReadResponse) XXX_Merge added in v0.0.4

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

func (*ReadResponse) XXX_Size added in v0.0.4

func (m *ReadResponse) XXX_Size() int

func (*ReadResponse) XXX_Unmarshal added in v0.0.4

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

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 NewDatastoreServer

func NewDatastoreServer(svc Datastore, hooks *twirp.ServerHooks) TwirpServer

type WriteRequest

type WriteRequest struct {
	// A string that uniquely identifies the community for which data is being
	// written. A recipient will not be able to decrypt the data unless they are
	// in possession of valid credentials to decrypt this data. This is a
	// required field.
	CommunityId string `protobuf:"bytes,5,opt,name=community_id,json=communityId,proto3" json:"community_id,omitempty"`
	// The data field here is the encrypted data to be stored for the specified
	// public key/entitlement policy. From the datastore's perspective this can
	// just be a slice of bytes, however zenroom does permit this data to
	// maintain some structure. From the datastores perspective however it treats
	// this data as a completely opaque bytes.
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// A token that uniquely identifies the device. This is a required field.
	DeviceToken          string   `protobuf:"bytes,3,opt,name=device_token,json=deviceToken,proto3" json:"device_token,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

WriteRequest is the message that is sent to the store in order to write data. Data is written keyed by the public key of the recipient, the id of the user, as well as an id representing the entitlement policy. Finally the encrypted data is sent as a chunk of bytes.

func (*WriteRequest) Descriptor

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

func (*WriteRequest) GetCommunityId added in v0.1.1

func (m *WriteRequest) GetCommunityId() string

func (*WriteRequest) GetData

func (m *WriteRequest) GetData() []byte

func (*WriteRequest) GetDeviceToken added in v0.0.5

func (m *WriteRequest) GetDeviceToken() string

func (*WriteRequest) ProtoMessage

func (*WriteRequest) ProtoMessage()

func (*WriteRequest) Reset

func (m *WriteRequest) Reset()

func (*WriteRequest) String

func (m *WriteRequest) String() string

func (*WriteRequest) XXX_DiscardUnknown added in v0.0.4

func (m *WriteRequest) XXX_DiscardUnknown()

func (*WriteRequest) XXX_Marshal added in v0.0.4

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

func (*WriteRequest) XXX_Merge added in v0.0.4

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

func (*WriteRequest) XXX_Size added in v0.0.4

func (m *WriteRequest) XXX_Size() int

func (*WriteRequest) XXX_Unmarshal added in v0.0.4

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

type WriteResponse

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

WriteResponse is a placeholder message returned from the call to write data to the store. Currently no fields have been identified, but keeping this as a separate type allows us to add fields as we identify them.

func (*WriteResponse) Descriptor

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

func (*WriteResponse) ProtoMessage

func (*WriteResponse) ProtoMessage()

func (*WriteResponse) Reset

func (m *WriteResponse) Reset()

func (*WriteResponse) String

func (m *WriteResponse) String() string

func (*WriteResponse) XXX_DiscardUnknown added in v0.0.4

func (m *WriteResponse) XXX_DiscardUnknown()

func (*WriteResponse) XXX_Marshal added in v0.0.4

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

func (*WriteResponse) XXX_Merge added in v0.0.4

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

func (*WriteResponse) XXX_Size added in v0.0.4

func (m *WriteResponse) XXX_Size() int

func (*WriteResponse) XXX_Unmarshal added in v0.0.4

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

Jump to

Keyboard shortcuts

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