notelib

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: AGPL-3.0, AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package notelib cert.go contains certificates

Package notelib config.go is where package-wide constants and vars are defined

Package notelib debug.go contains things that assist in debugging

Package notelib discover.go is the notehub discovery handling support

Package notelib err.go contains things that assist in error handling

Package notelib file.go is a 'storage driver' for a standard hierarchical file system

Package notelib fileio.go is the lowest level I/O driver underlying the file transport

Package notelib hubreq.go is the service-side complement to the Notehub client-side package

Package notelib notefile.go handles management and sync of collections of individual notes

Package notelib notebox.go deals with the handling of the sync'ed container of a set of related notefiles

Package notelib notefile.go handles management and sync of collections of individual notes

Package notelib notehub-defs contains device-hub RPC protocol definitions

Package notelib is a generated protocol buffer package.

Package notelib notehub.proto are the protocol definitions for notebox-notehub comms

It is generated from these files:

notehub.proto

It has these top-level messages:

NotehubPB

Package notelib notelib.go has certain internal definitions, placed here so that they parallel the clang version.

Package notelib storage.go is the class definition for storage drivers

Package notelib wire.go handles all conversions between the RPC's req/rsp structure and compressed on-wire formats

Index

Constants

View Source
const BulkNoteFormatV1 = 0x00000001

BulkNoteFormatV1 is the first and only version

View Source
const HTTPUserAgent = "notes"

HTTPUserAgent is the HTTP user agent for all our uses of HTTP

View Source
const ReservedIDDelimiter = ","

ReservedIDDelimiter is used to separate lists of noteIDs, notefileIDs, endpointIDs, thus is invalid in names

Variables

This section is empty.

Functions

func BulkDecodeEntry

func BulkDecodeEntry(context *BulkTemplateContext, i int) (body map[string]interface{}, payload []byte, when int64, where int64)

BulkDecodeEntry extract a JSON object from the binary

func Checkpoint added in v0.1.13

func Checkpoint() (err error)

Checkpoint all noteboxes and purge closed noteboxes

func CreateNotebox

func CreateNotebox(endpointID string, boxStorage string) (err error)

CreateNotebox creates a notebox on this endpoint

func DebugSet

func DebugSet(which string, value string)

DebugSet sets the debug variable

func Delete

func Delete(boxStorage string) (err error)

Delete deletes a closed Notebox, and releases its storage.

func ErrorContains

func ErrorContains(err error, errKeyword string) bool

ErrorContains tests to see if an error contains an error keyword that we might expect

func ErrorResponse

func ErrorResponse(err error) (response []byte)

ErrorResponse creates a simple JSON response given an error

func ErrorString

func ErrorString(err error) string

ErrorString safely returns a string from any error, returning "" for nil

func FileCleanName added in v0.1.5

func FileCleanName(filename string) string

FileCleanName generates a clean filename with correct extension from a filename input

func FileDefaultStorageObject

func FileDefaultStorageObject() string

FileDefaultStorageObject gives a deterministic storage object name from two components

func FileSetHandler

func FileSetHandler(newfio *Fileio)

FileSetHandler sets an alternate file I/O package

func FileSetStorageLocation

func FileSetStorageLocation(root string)

FileSetStorageLocation sets the root location for storage

func FileStorageObject

func FileStorageObject(containerName string) string

FileStorageObject gives a deterministic storage object name from two components

func GetNotecardSecureElementRootCertificateAsPEM

func GetNotecardSecureElementRootCertificateAsPEM() (cert []byte)

GetNotecardSecureElementRootCertificateAsPEM is the ST Microelectronics root certificate used to generate the certificate embedded in every Notecard's STSAFE-A100 secure element at point of chip manufacture.

func HubDiscover

func HubDiscover(deviceUID string, deviceSN string, productUID string) (hubSessionTicket string, hubEndpointID string, appUID string, deviceStorageObject string, err error)

HubDiscover ensures that we've read the local server's discover info, and return the Hub's Endpoint ID

func HubErrorResponse added in v0.2.4

func HubErrorResponse(session *HubSessionContext, errorMessage string) (result []byte)

HubErrorResponse creates an error response message to be sent to the client device, and terminates the session so that no further requests can be processed.

func HubRequest

func HubRequest(session *HubSessionContext, content []byte, event EventFunc, context interface{}) (result []byte, err error)

HubRequest creates a request message from a map of arguments, given an optional context parameter for fields that are shared across requests that happen within a single session. The return arguments should be interpreted as follows: - if err is returned, do not return a reply to the remote requestor - if err is nil, always send result back to request

func HubSetAccessControl added in v0.2.6

func HubSetAccessControl(fn NoteboxAccessFunc)

HubSetAccessControl sets the global notebox function to check access assertions

func HubSetDeviceNotifications

func HubSetDeviceNotifications(fn GetNotificationFunc)

HubSetDeviceNotifications sets the hub notification

func HubSetDiscover

func HubSetDiscover(fn DiscoverFunc)

HubSetDiscover sets the global discovery function

func HubSetNoteboxInit

func HubSetNoteboxInit(fn NoteboxInitFunc)

HubSetNoteboxInit sets the global notebox function to update env vars

func HubSetReadFile

func HubSetReadFile(fn ReadFileFunc)

HubSetReadFile sets the read file func

func HubSetSignal

func HubSetSignal(fn SignalFunc)

HubSetSignal sets the web request function

func HubSetWebRequest

func HubSetWebRequest(fn WebRequestFunc)

HubSetWebRequest sets the web request function

func Merge

func Merge(localNote *note.Note, incomingNote *note.Note) note.Note

Merge the contents of two Notes

func NotefileAttributesFromID

func NotefileAttributesFromID(notefileID string) (isQueue bool, syncToHub bool, syncFromHub bool, secure bool, reserved bool, err error)

NotefileAttributesFromID extracts attributes implied by the notefileID

func NotefileIDIsReserved added in v0.2.7

func NotefileIDIsReserved(notefileID string) bool

NotefileIDIsReserved returns true if the notefileID is reserved

func OLCFromINT64

func OLCFromINT64(code int64) (olc string)

OLCFromINT64 converts a 64-bit OLC code into a string

func OLCToINT64

func OLCToINT64(olc string) (result int64)

OLCToINT64 converts an OLC string into a 64-bit code

func Printf

func Printf(format string, args ...interface{})

Printf is an externally-callable version of same, for server use so it doesn't get held up writing to console

func RegisterTLSSupport

func RegisterTLSSupport()

RegisterTLSSupport tells the discover module that we do support TLS

func TLSSupport

func TLSSupport() bool

TLSSupport tells the discover module that we do support TLS

func TimeZoneNameToNumber added in v0.2.3

func TimeZoneNameToNumber(name string) int

TimeZoneNameToNumber converts a timezone number to a name

func TimeZoneNumberToCountry added in v0.2.3

func TimeZoneNumberToCountry(num int) string

TimeZoneNumberToCountry retrieves the country from the name

func TimeZoneNumberToName added in v0.2.3

func TimeZoneNumberToName(num int) string

TimeZoneNumberToName converts a timezone name to a number

func WireBarsFromSession added in v0.2.5

func WireBarsFromSession(session *HubSessionContext) (rat string, bars uint32)

WireBarsFromSession extracts device's perception of the number of bars of signal from a session

func WireExtractSessionContext

func WireExtractSessionContext(wire []byte, session *HubSessionContext) (err error)

WireExtractSessionContext extracts session context from the wire message

func WireReadRequest

func WireReadRequest(conn net.Conn, waitIndefinitely bool) (bytesRead uint32, request []byte, err error)

WireReadRequest reads a message from the specified reader

Types

type BulkBody

type BulkBody struct {
	// The format of the encoded binary note
	NoteFormat uint32 `json:"format,omitempty"`
	// The JSON of the Note template for this notefile.	 Note that we keep this in text form because
	// the order of the fields is relevant to the binary encoding derived from the JSON, and the various
	// encoders/decoders in the data processing pipeline won't retain field order.
	NoteTemplate           string `json:"template_body,omitempty"`
	NoteTemplatePayloadLen int    `json:"template_payload,omitempty"`
}

BulkBody is the bulk data note body

type BulkTemplateContext

type BulkTemplateContext struct {
	Template              string
	TemplatePayloadLen    int
	TemplatePayloadOffset int
	TemplateFlagsOffset   int
	Payload               []byte
	PayloadEntries        int
	PayloadEntryLength    int
}

BulkTemplateContext is the context for the bulk template

func BulkDecodeTemplate

func BulkDecodeTemplate(templateBodyJSON []byte, compressedPayload []byte) (context BulkTemplateContext, entries int, err error)

BulkDecodeTemplate decodes the template

type DiscoverFunc

type DiscoverFunc func(edgeUID string, deviceSN string, productUID string, hostname string) (info DiscoverInfo, err error)

DiscoverFunc is the func to retrieve discovery info for this server

type DiscoverInfo

type DiscoverInfo struct {
	HubEndpointID                 string
	HubSessionHandler             string
	HubSessionTicket              string
	HubDeviceStorageObject        string
	HubDeviceAppUID               string
	HubTimeNs                     int64
	HubSessionTicketExpiresTimeNs int64
	HubCert                       []byte
}

DiscoverInfo is the information returned by DiscoverFunc

type EventFunc

type EventFunc func(context interface{}, local bool, file *Notefile, data *note.Event) (err error)

EventFunc is the func to get called whenever there is a note add/update/delete

type Fileio

type Fileio struct {
	Exists    FileioExistsFunc
	Create    FileioCreateFunc
	Delete    FileioDeleteFunc
	ReadJSON  FileioReadJSONFunc
	WriteJSON FileioWriteJSONFunc
}

Fileio defines a set of functions for alternative file I/O

type FileioCreateFunc

type FileioCreateFunc func(path string) (err error)

FileioCreateFunc creates a file

type FileioDeleteFunc

type FileioDeleteFunc func(path string) (err error)

FileioDeleteFunc deletes a file

type FileioExistsFunc

type FileioExistsFunc func(path string) (exists bool, err error)

FileioExistsFunc checks for file existence

type FileioReadJSONFunc

type FileioReadJSONFunc func(path string) (data []byte, err error)

FileioReadJSONFunc reads a JSON file

type FileioWriteJSONFunc

type FileioWriteJSONFunc func(path string, data []byte) (err error)

FileioWriteJSONFunc writes a JSON file

type GetNotificationFunc

type GetNotificationFunc func(deviceUID string, productUID string) (notifications []string, err error)

GetNotificationFunc retrieves hub notifications to be sent to client

type HubSessionContext

type HubSessionContext struct {
	Active           bool
	Secure           bool
	Terminated       bool
	Discovery        bool
	Notification     bool
	BeganSec         int
	DeviceUID        string
	DeviceSN         string
	ProductUID       string
	DeviceEndpointID string
	HubEndpointID    string
	HubSessionTicket string
	Transactions     int
	EventQ           *chan HubSessionEvent
	LatestUpdated    bool
	Latest           *map[string]note.Event
	Notefiles        []string
	NotefilesUpdated bool
	RouteInfo        map[string]interface{}
	// Fields that are useful when logged in a session log
	Session note.DeviceSession
	// Cached Where info, used by event processing for efficiency
	CachedWhereLat      float64
	CachedWhereLon      float64
	CachedWhereLocation string
	CachedWhereCountry  string
	CachedWhereTimeZone string
}

HubSessionContext are the fields that are coordinated between the client and the server for the duration of an open session. The "Active" flag is true if the client believes that the service is actively maintaining it in parallel, and vice-versa on the service side.

type HubSessionEvent

type HubSessionEvent struct {
	Session HubSessionContext
	Local   bool
	File    Notefile
	Event   note.Event
	Exit    bool
}

HubSessionEvent is an event queue entry, containing everything necessary to process an event

type Notebox

type Notebox struct {
	// contains filtered or unexported fields
}

Notebox is the in-memory data structure for an open notebox

func OpenEndpointNotebox

func OpenEndpointNotebox(localEndpointID string, boxLocalStorage string, create bool) (box *Notebox, err error)

OpenEndpointNotebox opens - creating if necessary - a notebox in File storage for an endpoint

func OpenNotebox

func OpenNotebox(localEndpointID string, boxLocalStorage string) (notebox *Notebox, err error)

OpenNotebox opens a local notebox into memory.

func (*Notebox) AddNote

func (box *Notebox) AddNote(endpointID string, notefileID string, noteID string, note note.Note) (err error)

AddNote adds a new note to a notefile, which is a VERY common operation

func (*Notebox) AddNotefile

func (box *Notebox) AddNotefile(notefileID string, notefileInfo *note.NotefileInfo) error

AddNotefile adds a new notefile to the notebox, and return "nil" if it already exists

func (*Notebox) CheckpointNotefile

func (box *Notebox) CheckpointNotefile(notefileID string) (err error)

CheckpointNotefile checkpoints an open Notefile to storage

func (*Notebox) ClearAllTrackers

func (box *Notebox) ClearAllTrackers(endpointID string) (err error)

ClearAllTrackers deletes all trackers for this endpoint in order to force a resync of all files

func (*Notebox) Close

func (box *Notebox) Close() (err error)

Close releases a notebox, but leaves it in-memory with a 0 refcount for low-overhead re-open

func (*Notebox) CreateNotefile

func (box *Notebox) CreateNotefile(isQueue bool) Notefile

CreateNotefile creates a new Notefile in-memory, which will ultimately be added to this Notebox

func (*Notebox) DeleteNote

func (box *Notebox) DeleteNote(endpointID string, notefileID string, noteID string) (err error)

DeleteNote deletes an existing note from notefile

func (*Notebox) DeleteNotefile

func (box *Notebox) DeleteNotefile(notefileID string) (err error)

DeleteNotefile deletes a closed Notefile, and releases its storage.

func (*Notebox) EndpointID

func (box *Notebox) EndpointID() string

EndpointID gets the notebox's endpoint ID

func (*Notebox) GetChangedNotefiles

func (box *Notebox) GetChangedNotefiles(endpointID string) (changedNotefiles []string, err error)

GetChangedNotefiles determines, for a given tracker, if there are changes in any notebox and, if so, for which ones.

func (*Notebox) GetChanges

func (box *Notebox) GetChanges(endpointID string, maxBatchSize int) (file Notefile, numChanges int, totalChanges int, totalNotes int, since int64, until int64, err error)

GetChanges retrieves the next batch of changes being tracked

func (*Notebox) GetEventInfo

func (box *Notebox) GetEventInfo() (deviceUID string, deviceSN string, productUID string)

GetEventInfo retrieves the info

func (*Notebox) GetNote

func (box *Notebox) GetNote(notefileID string, noteID string) (note note.Note, err error)

GetNote gets a note from a notefile

func (*Notebox) GetNotefileInfo

func (box *Notebox) GetNotefileInfo(notefileID string) (notefileInfo note.NotefileInfo, err error)

GetNotefileInfo retrieves info about a specific notefile

func (*Notebox) MergeNotebox

func (box *Notebox) MergeNotebox(fromBoxfile Notefile) (err error)

MergeNotebox takes a "changes" Notefile from box.GetChanges, and integrates those changes into the current notebox.

func (*Notebox) Notefile

func (box *Notebox) Notefile() (notefile *Notefile)

Notefile get the pointer to the notefile associated with the notebox, so that we can use standard Notefile methods to synchronize the Notebox.

func (*Notebox) NotefileExists added in v0.1.10

func (box *Notebox) NotefileExists(notefileID string) (present bool)

NotefileExists returns true if notefile exists and is not deleted

func (*Notebox) Notefiles

func (box *Notebox) Notefiles(includeTombstones bool) (notefiles []string, err error)

Notefiles gets a list of all openable notefiles in the current boxfile

func (*Notebox) OpenNotefile

func (box *Notebox) OpenNotefile(notefileID string) (iOpenfile *OpenNotefile, notefile *Notefile, err error)

OpenNotefile opens a notefile, reading it from storage and bumping its refcount. As such, you MUST pair this with a call to CloseNotefile. Note that this function must work for the "" NotefileID (when opening the notebox "|" instance), so don't add a check that would prohibit this.

func (*Notebox) Request

func (box *Notebox) Request(endpointID string, reqJSON []byte) (rspJSON []byte)

Request performs a local operation using the JSON API

func (*Notebox) SetClientInfo added in v0.2.6

func (box *Notebox) SetClientInfo(httpReq *http.Request, httpRsp http.ResponseWriter)

SetClientInfo sets information that is necessary for HTTP client access checking

func (*Notebox) SetEventInfo

func (box *Notebox) SetEventInfo(deviceUID string, deviceSN string, productUID string, appUID string, iFn EventFunc, iCtx interface{}) error

SetEventInfo establishes default information used for change notification on notefiles opened in the box

func (*Notebox) SetNotefileInfo

func (box *Notebox) SetNotefileInfo(notefileID string, notefileInfo note.NotefileInfo) (err error)

SetNotefileInfo sets the info about a notefile that is allowed to be changed after notefile creation

func (*Notebox) UpdateChangeTracker

func (box *Notebox) UpdateChangeTracker(endpointID string, since int64, until int64) error

UpdateChangeTracker updates the tracker once changes have been processed

func (*Notebox) UpdateNote

func (box *Notebox) UpdateNote(endpointID string, notefileID string, noteID string, note note.Note) (err error)

UpdateNote updates an existing note from notefile

func (*Notebox) VerifyAccess added in v0.2.6

func (box *Notebox) VerifyAccess(resource string, actions string) (err error)

VerifyAccess checks an assertion of access

type NoteboxAccessFunc added in v0.2.6

type NoteboxAccessFunc func(httpReq *http.Request, httpRsp http.ResponseWriter, resource string, actions string) (err error)

NoteboxAccessFunc is the func to check an access assertion

type NoteboxInitFunc

type NoteboxInitFunc func(box *Notebox) (err error)

NoteboxInitFunc is the func to initialize the notebox at the start of a session

type NoteboxInstance added in v0.2.6

type NoteboxInstance struct {
	// contains filtered or unexported fields
}

NoteboxInstance is the in-memory data structure for an open notebox

type Notefile

type Notefile struct {
	Queue    bool                 `json:"Q,omitempty"`
	Notes    map[string]note.Note `json:"N,omitempty"`
	Trackers map[string]Tracker   `json:"T,omitempty"`
	Change   int64                `json:"C,omitempty"`
	// contains filtered or unexported fields
}

Notefile is The outermost data structure of a Notefile JSON object, containing a set of notes that may be synchronized.

func CreateNotefile

func CreateNotefile(isQueue bool) Notefile

CreateNotefile instantiates and initializes a new Notefile, and prepares it so that notes may be added on behalf of the specified endpoint. The ID of that endpoint may be changed at any time and is merely an affordance so that we don't need to put the endpointID onto every Note call.

func (*Notefile) AddNote

func (nf *Notefile) AddNote(endpointID string, noteID string, xnote note.Note) (err error)

AddNote adds a newly-created Note to a Notefile. After the note is added to the Notefile, it should no longer be used because its contents is copied into the Notefile. If a unique ID for this note isn't supplied, one is generated. Note that if this is a queue, AddNote adds the newly-created note in a pre-deleted state. This is quite useful for notefiles that are being "tracked", because after all trackers receive it, they will undelete it and thus it will be present everywhere except the source. This is an intentional asymmetry in synchronization that is primarily useful when sending "to hub" or "from hub". By convention, sent notes should be deleted after they have been processed by the recipient(s).

func (*Notefile) AddTracker

func (nf *Notefile) AddTracker(trackerID string) error

AddTracker creates an object that will be used for performing incremental queries against the notefile. Do NOT create trackers that won't actively be used, because deletion tombstones will remain in the Notefile for as long as necessary by the oldest pending tracker. In other words, delete trackers when not in use.

func (*Notefile) AreChanges

func (nf *Notefile) AreChanges(trackerID string) (areChanges bool, err error)

AreChanges determines whether or not there are any changes pending for this endpoint

func (*Notefile) ClearTracker

func (nf *Notefile) ClearTracker(trackerID string) error

ClearTracker clears the change count in a tracker

func (*Notefile) Close

func (nf *Notefile) Close()

Close closes and frees the Notefile

func (*Notefile) CountNotes

func (nf *Notefile) CountNotes(includeTombstones bool) (count int)

CountNotes returns the count of notes within this notefile

func (*Notefile) DeleteNote

func (nf *Notefile) DeleteNote(endpointID string, noteID string) error

DeleteNote sets the deleted flag on an existing note from in a Notefile, marking it so that it will be purged at a later time when safe to do so from a synchronization perspective.

func (*Notefile) DeleteTracker

func (nf *Notefile) DeleteTracker(trackerID string) error

DeleteTracker deletes an existing tracker

func (*Notefile) GetChanges

func (nf *Notefile) GetChanges(endpointID string, maxBatchSize int) (chgfile Notefile, numChanges int, totalChanges int, totalNotes int, since int64, until int64, err error)

GetChanges retrieves the next batch of changes being tracked, initializing a new tracker if necessary.

func (*Notefile) GetLeastRecentNoteID added in v0.2.7

func (nf *Notefile) GetLeastRecentNoteID() (noteID string, err error)

GetLeastRecentNoteID enumerates and returns the first logical note to dequeue

func (*Notefile) GetNote

func (nf *Notefile) GetNote(noteID string) (xnote note.Note, err error)

GetNote retrieves a copy of a note from a Notefile, by ID

func (*Notefile) GetTrackers

func (nf *Notefile) GetTrackers() []string

GetTrackers gets a list of the trackers for a given notefile

func (*Notefile) Info

func (nf *Notefile) Info() (info note.NotefileInfo)

Info returns the notefileinfo as it was when this notefile was opened

func (*Notefile) InternalizePayload

func (nf *Notefile) InternalizePayload(xp []byte) (err error)

InternalizePayload populates the Payload field inside a set of notes in a notefile from an external source

func (*Notefile) IsTracker

func (nf *Notefile) IsTracker(trackerID string) (isTracker bool)

IsTracker returns TRUE if there's a tracker present, else false

func (*Notefile) MergeNotefile

func (nf *Notefile) MergeNotefile(fromNotefile Notefile) error

MergeNotefile combines/merges the entire contents of one Notefile into another

func (*Notefile) Modified

func (nf *Notefile) Modified() int

Modified returns the number of times this has been modified in-memory since being opened. Note that this is not persistent, and is intended to be used for checkpointing.

func (*Notefile) NewNoteID

func (nf *Notefile) NewNoteID(endpointID string) string

NewNoteID Generates a new unique Note ID

func (*Notefile) NoteIDs

func (nf *Notefile) NoteIDs(includeTombstones bool) (noteIDs []string)

NoteIDs retrieves the list of all Note IDs in the notefile

func (*Notefile) Notefile

func (nf *Notefile) Notefile() (notefileID string)

Notefile returns the notefileID for this notefile

func (*Notefile) PurgeTombstones

func (nf *Notefile) PurgeTombstones(ignoreEndpointID string) (err error)

PurgeTombstones purges tombstones that are no longer needed by trackers

func (*Notefile) SetEventInfo

func (nf *Notefile) SetEventInfo(deviceUID string, deviceSN string, productUID string, appUID string, fn EventFunc, fnctx interface{}) error

SetEventInfo supplies information used for change notification

func (*Notefile) UpdateChangeTracker

func (nf *Notefile) UpdateChangeTracker(endpointID string, since int64, until int64) (err error)

UpdateChangeTracker updates the tracker and purges tombstones after changes have been committed

func (*Notefile) UpdateNote

func (nf *Notefile) UpdateNote(endpointID string, noteID string, xnote note.Note) error

UpdateNote updates an existing note within a Notefile, as well as updating all its history and conflict metadata as appropriate.

type NotehubPB

type NotehubPB struct {
	Version                        *int64  `protobuf:"varint,1,opt,name=Version" json:"Version,omitempty"`
	MessageType                    *string `protobuf:"bytes,2,opt,name=MessageType" json:"MessageType,omitempty"`
	Error                          *string `protobuf:"bytes,3,opt,name=Error" json:"Error,omitempty"`
	DeviceUID                      *string `protobuf:"bytes,4,opt,name=DeviceUID" json:"DeviceUID,omitempty"`
	DeviceEndpointID               *string `protobuf:"bytes,5,opt,name=DeviceEndpointID" json:"DeviceEndpointID,omitempty"`
	HubTimeNs                      *int64  `protobuf:"varint,6,opt,name=HubTimeNs" json:"HubTimeNs,omitempty"`
	HubEndpointID                  *string `protobuf:"bytes,7,opt,name=HubEndpointID" json:"HubEndpointID,omitempty"`
	HubSessionTicket               *string `protobuf:"bytes,8,opt,name=HubSessionTicket" json:"HubSessionTicket,omitempty"`
	HubSessionHandler              *string `protobuf:"bytes,9,opt,name=HubSessionHandler" json:"HubSessionHandler,omitempty"`
	HubSessionTicketExpiresTimeSec *int64  `protobuf:"varint,10,opt,name=HubSessionTicketExpiresTimeSec" json:"HubSessionTicketExpiresTimeSec,omitempty"`
	NotefileID                     *string `protobuf:"bytes,11,opt,name=NotefileID" json:"NotefileID,omitempty"`
	NotefileIDs                    *string `protobuf:"bytes,12,opt,name=NotefileIDs" json:"NotefileIDs,omitempty"`
	Since                          *int64  `protobuf:"varint,13,opt,name=Since" json:"Since,omitempty"`
	Until                          *int64  `protobuf:"varint,14,opt,name=Until" json:"Until,omitempty"`
	MaxChanges                     *int64  `protobuf:"varint,15,opt,name=MaxChanges" json:"MaxChanges,omitempty"`
	DeviceSN                       *string `protobuf:"bytes,16,opt,name=DeviceSN" json:"DeviceSN,omitempty"`
	NoteID                         *string `protobuf:"bytes,17,opt,name=NoteID" json:"NoteID,omitempty"`
	SessionIDPrev                  *int64  `protobuf:"varint,18,opt,name=SessionIDPrev" json:"SessionIDPrev,omitempty"`
	SessionIDNext                  *int64  `protobuf:"varint,19,opt,name=SessionIDNext" json:"SessionIDNext,omitempty"`
	SessionIDMismatch              *bool   `protobuf:"varint,20,opt,name=SessionIDMismatch" json:"SessionIDMismatch,omitempty"`
	Bytes1                         *int64  `protobuf:"varint,21,opt,name=Bytes1" json:"Bytes1,omitempty"`
	Bytes2                         *int64  `protobuf:"varint,22,opt,name=Bytes2" json:"Bytes2,omitempty"`
	Bytes3                         *int64  `protobuf:"varint,23,opt,name=Bytes3" json:"Bytes3,omitempty"`
	Bytes4                         *int64  `protobuf:"varint,24,opt,name=Bytes4" json:"Bytes4,omitempty"`
	ProductUID                     *string `protobuf:"bytes,25,opt,name=ProductUID" json:"ProductUID,omitempty"`
	UsageProvisioned               *int64  `protobuf:"varint,26,opt,name=UsageProvisioned" json:"UsageProvisioned,omitempty"`
	UsageRcvdBytes                 *uint32 `protobuf:"varint,27,opt,name=UsageRcvdBytes" json:"UsageRcvdBytes,omitempty"`
	UsageSentBytes                 *uint32 `protobuf:"varint,28,opt,name=UsageSentBytes" json:"UsageSentBytes,omitempty"`
	UsageTCPSessions               *uint32 `protobuf:"varint,29,opt,name=UsageTCPSessions" json:"UsageTCPSessions,omitempty"`
	UsageTLSSessions               *uint32 `protobuf:"varint,30,opt,name=UsageTLSSessions" json:"UsageTLSSessions,omitempty"`
	UsageRcvdNotes                 *uint32 `protobuf:"varint,31,opt,name=UsageRcvdNotes" json:"UsageRcvdNotes,omitempty"`
	UsageSentNotes                 *uint32 `protobuf:"varint,32,opt,name=UsageSentNotes" json:"UsageSentNotes,omitempty"`
	CellID                         *string `protobuf:"bytes,33,opt,name=CellID" json:"CellID,omitempty"`
	NotificationSession            *bool   `protobuf:"varint,34,opt,name=NotificationSession" json:"NotificationSession,omitempty"`
	Voltage100                     *int32  `protobuf:"varint,35,opt,name=Voltage100" json:"Voltage100,omitempty"`
	Temp100                        *int32  `protobuf:"varint,36,opt,name=Temp100" json:"Temp100,omitempty"`
	ContinuousSession              *bool   `protobuf:"varint,37,opt,name=ContinuousSession" json:"ContinuousSession,omitempty"`
	XXX_unrecognized               []byte  `json:"-"`
}

func (*NotehubPB) Descriptor

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

func (*NotehubPB) GetBytes1

func (m *NotehubPB) GetBytes1() int64

func (*NotehubPB) GetBytes2

func (m *NotehubPB) GetBytes2() int64

func (*NotehubPB) GetBytes3

func (m *NotehubPB) GetBytes3() int64

func (*NotehubPB) GetBytes4

func (m *NotehubPB) GetBytes4() int64

func (*NotehubPB) GetCellID

func (m *NotehubPB) GetCellID() string

func (*NotehubPB) GetContinuousSession added in v0.2.7

func (m *NotehubPB) GetContinuousSession() bool

func (*NotehubPB) GetDeviceEndpointID

func (m *NotehubPB) GetDeviceEndpointID() string

func (*NotehubPB) GetDeviceSN

func (m *NotehubPB) GetDeviceSN() string

func (*NotehubPB) GetDeviceUID

func (m *NotehubPB) GetDeviceUID() string

func (*NotehubPB) GetError

func (m *NotehubPB) GetError() string

func (*NotehubPB) GetHubEndpointID

func (m *NotehubPB) GetHubEndpointID() string

func (*NotehubPB) GetHubSessionHandler

func (m *NotehubPB) GetHubSessionHandler() string

func (*NotehubPB) GetHubSessionTicket

func (m *NotehubPB) GetHubSessionTicket() string

func (*NotehubPB) GetHubSessionTicketExpiresTimeSec

func (m *NotehubPB) GetHubSessionTicketExpiresTimeSec() int64

func (*NotehubPB) GetHubTimeNs

func (m *NotehubPB) GetHubTimeNs() int64

func (*NotehubPB) GetMaxChanges

func (m *NotehubPB) GetMaxChanges() int64

func (*NotehubPB) GetMessageType

func (m *NotehubPB) GetMessageType() string

func (*NotehubPB) GetNoteID

func (m *NotehubPB) GetNoteID() string

func (*NotehubPB) GetNotefileID

func (m *NotehubPB) GetNotefileID() string

func (*NotehubPB) GetNotefileIDs

func (m *NotehubPB) GetNotefileIDs() string

func (*NotehubPB) GetNotificationSession

func (m *NotehubPB) GetNotificationSession() bool

func (*NotehubPB) GetProductUID

func (m *NotehubPB) GetProductUID() string

func (*NotehubPB) GetSessionIDMismatch

func (m *NotehubPB) GetSessionIDMismatch() bool

func (*NotehubPB) GetSessionIDNext

func (m *NotehubPB) GetSessionIDNext() int64

func (*NotehubPB) GetSessionIDPrev

func (m *NotehubPB) GetSessionIDPrev() int64

func (*NotehubPB) GetSince

func (m *NotehubPB) GetSince() int64

func (*NotehubPB) GetTemp100

func (m *NotehubPB) GetTemp100() int32

func (*NotehubPB) GetUntil

func (m *NotehubPB) GetUntil() int64

func (*NotehubPB) GetUsageProvisioned

func (m *NotehubPB) GetUsageProvisioned() int64

func (*NotehubPB) GetUsageRcvdBytes

func (m *NotehubPB) GetUsageRcvdBytes() uint32

func (*NotehubPB) GetUsageRcvdNotes

func (m *NotehubPB) GetUsageRcvdNotes() uint32

func (*NotehubPB) GetUsageSentBytes

func (m *NotehubPB) GetUsageSentBytes() uint32

func (*NotehubPB) GetUsageSentNotes

func (m *NotehubPB) GetUsageSentNotes() uint32

func (*NotehubPB) GetUsageTCPSessions

func (m *NotehubPB) GetUsageTCPSessions() uint32

func (*NotehubPB) GetUsageTLSSessions

func (m *NotehubPB) GetUsageTLSSessions() uint32

func (*NotehubPB) GetVersion

func (m *NotehubPB) GetVersion() int64

func (*NotehubPB) GetVoltage100

func (m *NotehubPB) GetVoltage100() int32

func (*NotehubPB) ProtoMessage

func (*NotehubPB) ProtoMessage()

func (*NotehubPB) Reset

func (m *NotehubPB) Reset()

func (*NotehubPB) String

func (m *NotehubPB) String() string

type OpenNotefile

type OpenNotefile struct {
	// contains filtered or unexported fields
}

OpenNotefile is the in-memory data structure for an open notefile

func (*OpenNotefile) Close

func (openfile *OpenNotefile) Close() (err error)

Close closes an open Notefile, decrementing its refcount and making it available for purging from memory if this is the last reference.

type ReadFileFunc

type ReadFileFunc func(appUID string, filetype string, key string, offset int32, length int32, compress bool, getInfo bool) (body []byte, payload []byte, err error)

ReadFileFunc is the func to read a byte range from the named file

type SignalFunc

type SignalFunc func(deviceUID string, bodyJSON []byte, payloadJSON []byte, session *HubSessionContext) (err error)

SignalFunc performs a web request on behalf of a device

type TimeZoneNames added in v0.2.3

type TimeZoneNames struct {
	Name string
	ID   int
}

TimeZoneNames is the struct for the table below

type Tracker

type Tracker struct {
	Change    int64 `json:"c,omitempty"`
	SessionID int64 `json:"i,omitempty"`
	Optimize  bool  `json:"o,omitempty"`
}

Tracker is the structure maintained on a per-endpoint basis. When created, the Active flag being false indicates that any GetChanges will return ALL notes in the file. Only after the tracking entity has received all notes at least once can it then switch into "Optimize" mode. When Optimizing, a tracking entity will not receive its own uploaded changes - thus preventing "loopback". (Loopback is not harmful per se, but it is suboptimal from a bandwidth perspective.)

type WebRequestFunc

type WebRequestFunc func(deviceUID string, productUID string, alias string, reqtype string, target string, bodyJSON []byte, payloadJSON []byte, session *HubSessionContext) (rspstatuscode int, rspBodyJSON []byte, rspPayloadJSON []byte, err error)

WebRequestFunc performs a web request on behalf of a device

Jump to

Keyboard shortcuts

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