Documentation
¶
Overview ¶
Package note errors.go contains programmatically-testable error strings
Index ¶
- Constants
- func ErrorClean(err error) error
- func ErrorContains(err error, errKeyword string) bool
- func ErrorString(err error) string
- func JSONToBody(bodyJSON []byte) (body map[string]interface{}, err error)
- func ObjectToBody(object interface{}) (body map[string]interface{}, err error)
- func ObjectToJSON(object interface{}) (bodyJSON []byte, err error)
- type DeviceSession
- type DeviceUsage
- type Event
- type EventApp
- type EventContact
- type EventContacts
- type EventLogEntry
- type History
- type Info
- type Note
- func (note *Note) Close()
- func (note *Note) Dup() Note
- func (note *Note) EndpointID() string
- func (note *Note) GetBody() []byte
- func (note *Note) GetConflicts() []Note
- func (note *Note) GetModified() (isAvailable bool, endpointID string, when string, where string, updates int32)
- func (note *Note) GetPayload() []byte
- func (note *Note) HasConflicts() bool
- func (note *Note) SetBody(body []byte) (err error)
- func (note *Note) SetPayload(payload []byte)
- type NotefileInfo
- type TowerLocation
Constants ¶
const DefaultDeviceEndpointID = ""
DefaultDeviceEndpointID is the default endpoint name of the edge, chosen for its length in protocol messages
const DefaultHubEndpointID = "1"
DefaultHubEndpointID is the default endpoint name of the hub, chosen for its length in protocol messages
const ErrCardIo = "{io}"
ErrCardIo (golint)
const EventAdd = "note.add"
EventAdd (golint)
const EventDelete = "note.delete"
EventDelete (golint)
const EventGet = "get"
EventGet (golint)
const EventNoAction = ""
EventNoAction (golint)
const EventPost = "post"
EventPost (golint)
const EventPut = "put"
EventPut (golint)
const EventUpdate = "note.update"
EventUpdate (golint)
const SyncPriorityHigh = 1
SyncPriorityHigh (golint)
const SyncPriorityHigher = 2
SyncPriorityHigher (golint)
const SyncPriorityHighest = 3
SyncPriorityHighest (golint)
const SyncPriorityLow = -1
SyncPriorityLow (golint)
const SyncPriorityLower = -2
SyncPriorityLower (golint)
const SyncPriorityLowest = -3
SyncPriorityLowest (golint)
const SyncPriorityNormal = 0
SyncPriorityNormal (golint)
Variables ¶
This section is empty.
Functions ¶
func ErrorClean ¶ added in v1.1.21
ErrorClean removes all error keywords from an error string
func ErrorContains ¶ added in v1.1.21
ErrorContains tests to see if an error contains an error keyword that we might expect
func ErrorString ¶ added in v1.1.21
ErrorString safely returns a string from any error, returning "" for nil
func JSONToBody ¶ added in v1.1.1
JSONToBody unmarshals the specify object and returns it as a map[string]interface{}
func ObjectToBody ¶ added in v1.1.1
ObjectToBody Marshals the specify object and returns it as map
func ObjectToJSON ¶ added in v1.1.1
ObjectToJSON Marshals the specify object and returns it as a []byte
Types ¶
type DeviceSession ¶
type DeviceSession struct {
// Session ID that can be mapped to the events created during that session
SessionUID string `json:"session,omitempty"`
// Info from the device structure
DeviceUID string `json:"device,omitempty"`
DeviceSN string `json:"sn,omitempty"`
ProductUID string `json:"product,omitempty"`
FleetUID string `json:"fleet,omitempty"`
// IP address of the session
Addr string `json:"addr,omitempty"`
// Cell ID where the session originated and quality ("mcc,mnc,lac,cellid")
CellID string `json:"cell,omitempty"`
// Signal strength/quality of the cell
Rssi int `json:"rssi,omitempty"`
Sinr int `json:"sinr,omitempty"`
// Last known tower location at beginning of session
Tower TowerLocation `json:"tower,omitempty"`
// Last known GPS location extracted from data flowing through session
WhereWhen int64 `json:"where_when,omitempty"`
WhereOLC string `json:"where,omitempty"`
WhereLat float64 `json:"where_lat,omitempty"`
WhereLon float64 `json:"where_lon,omitempty"`
WhereLocation string `json:"where_location,omitempty"`
WhereCountry string `json:"where_country,omitempty"`
WhereTimeZone string `json:"where_timezone,omitempty"`
// Total device usage at the beginning of the period
This DeviceUsage `json:"this,omitempty"`
// Total device usage at the beginning of the next period, whenever it happens to occur
Next DeviceUsage `json:"next,omitempty"`
// Usage during the period - initially estimated, but then corrected when we get to the next period
Period DeviceUsage `json:"period,omitempty"`
// Physical device info
Voltage float64 `json:"voltage,omitempty"`
Temp float64 `json:"temp,omitempty"`
// Development mode
Development bool `json:"dev,omitempty"`
// For keeping track of when the last work was done for a session
LastWorkDone int64
}
DeviceSession is the basic unit of recorded device usage history
type DeviceUsage ¶
type DeviceUsage struct {
Since int64 `json:"since,omitempty"`
DurationSecs uint32 `json:"duration,omitempty"`
RcvdBytes uint32 `json:"bytes_rcvd,omitempty"`
SentBytes uint32 `json:"bytes_sent,omitempty"`
TCPSessions uint32 `json:"sessions_tcp,omitempty"`
TLSSessions uint32 `json:"sessions_tls,omitempty"`
RcvdNotes uint32 `json:"notes_rcvd,omitempty"`
SentNotes uint32 `json:"notes_sent,omitempty"`
}
DeviceUsage is the device usage metric representing values from the beginning of time, since Provisioned
type Event ¶
type Event struct {
Body *map[string]interface{} `json:"body,omitempty"`
Req string `json:"req,omitempty"`
Rsp string `json:"rsp,omitempty"`
Error string `json:"err,omitempty"`
When int64 `json:"when,omitempty"`
Where string `json:"where,omitempty"`
WhereLat float64 `json:"where_lat,omitempty"`
WhereLon float64 `json:"where_lon,omitempty"`
WhereLocation string `json:"where_location,omitempty"`
WhereCountry string `json:"where_country,omitempty"`
WhereTimeZone string `json:"where_timezone,omitempty"`
Routed int64 `json:"routed,omitempty"`
NoteID string `json:"note,omitempty"`
NotefileID string `json:"file,omitempty"`
Updates int32 `json:"updates,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Sent bool `json:"queued,omitempty"`
Bulk bool `json:"bulk,omitempty"`
TowerCountry string `json:"tower_country,omitempty"`
TowerLocation string `json:"tower_location,omitempty"`
TowerTimeZone string `json:"tower_timezone,omitempty"`
TowerLat float64 `json:"tower_lat,omitempty"`
TowerLon float64 `json:"tower_lon,omitempty"`
TowerID string `json:"tower_id,omitempty"`
LogAttn bool `json:"logattn,omitempty"`
Log map[string]EventLogEntry `json:"log,omitempty"`
App *EventApp `json:"project,omitempty"`
DeviceContact *EventContact `json:"device_contact,omitempty"`
EndpointID string `json:"endpoint,omitempty"`
DeviceSN string `json:"sn,omitempty"`
DeviceUID string `json:"device,omitempty"`
ProductUID string `json:"product,omitempty"`
SessionUID string `json:"session,omitempty"`
EventUID string `json:"event,omitempty"`
Payload []byte `json:"payload,omitempty"`
}
Event is the request structure passed to the Notification proc
type EventApp ¶
type EventApp struct {
AppUID string `json:"id,omitempty"`
AppLabel string `json:"name,omitempty"`
Contacts EventContacts `json:"contacts,omitempty"`
}
EventApp has information about the app
type EventContact ¶
type EventContact struct {
Name string `json:"name,omitempty"`
Affiliation string `json:"org,omitempty"`
Role string `json:"role,omitempty"`
Email string `json:"email,omitempty"`
}
EventContact has the basic contact info structure
type EventContacts ¶
type EventContacts struct {
Admin *EventContact `json:"admin,omitempty"`
Tech *EventContact `json:"tech,omitempty"`
}
EventContacts has contact info for this app
type EventLogEntry ¶
type EventLogEntry struct {
Attn bool `json:"attn,omitempty"`
Status string `json:"status,omitempty"`
Text string `json:"text,omitempty"`
}
EventLogEntry is the log entry used by notification processing
type History ¶
type History struct {
When int64 `json:"w,omitempty"`
Where string `json:"l,omitempty"`
EndpointID string `json:"e,omitempty"`
Sequence int32 `json:"s,omitempty"`
}
History records the update history, optimized so that if the most recent entry is by the same endpoint as an update/delete, that entry is re-used. The primary use of History is for conflict detection, and you don't need to detect conflicts against yourself.
type Info ¶
type Info struct {
Body *map[string]interface{} `json:"body,omitempty"`
Payload *[]byte `json:"payload,omitempty"`
Deleted bool `json:"deleted,omitempty"`
}
Info is a general "content" structure
type Note ¶
type Note struct {
Body map[string]interface{} `json:"b,omitempty"`
Payload []byte `json:"p,omitempty"`
Change int64 `json:"c,omitempty"`
Histories *[]History `json:"h,omitempty"`
Conflicts *[]Note `json:"x,omitempty"`
Updates int32 `json:"u,omitempty"`
Deleted bool `json:"d,omitempty"`
Sent bool `json:"s,omitempty"`
Bulk bool `json:"k,omitempty"`
XPOff uint32 `json:"O,omitempty"`
XPLen uint32 `json:"L,omitempty"`
}
Note is the most fundamental data structure, containing user data referred to as its "body" and its "payload". All access to these fields, and changes to these fields, must be done indirectly through the note API.
func CreateNote ¶
CreateNote creates the core data structure for an object, given a JSON body
func (*Note) EndpointID ¶
EndpointID determines the endpoint that last modified the note
func (*Note) GetConflicts ¶
GetConflicts fetches the conflicts, so that they may be displayed
func (*Note) GetModified ¶
func (note *Note) GetModified() (isAvailable bool, endpointID string, when string, where string, updates int32)
GetModified retrieves information about the note's modification
func (*Note) GetPayload ¶
GetPayload retrieves the Payload from a given Note
func (*Note) HasConflicts ¶
HasConflicts determines whether or not a given Note has conflicts
func (*Note) SetBody ¶
SetBody sets the application-supplied Body field of a given Note given some JSON
func (*Note) SetPayload ¶
SetPayload sets the application-supplied Payload field of a given Note, which must be binary bytes that will ultimately be rendered as base64 in JSON
type NotefileInfo ¶
type NotefileInfo struct {
// The count of modified notes in this notefile. This is used in the Req API, but not in the Notebox info
Changes int `json:"changes,omitempty"`
// This is a unidirectional "to-hub" or "from-hub" endpoint
SyncHubEndpointID string `json:"sync_hub_endpoint,omitempty"`
// Relative positive/negative priority of data, with 0 being normal
SyncPriority int `json:"sync_priority,omitempty"`
// Timed: Target for sync period, if modified and if the value hasn't been synced sooner
SyncPeriodSecs int `json:"sync_secs,omitempty"`
// ReqTime is specified if notes stored in this notefile must have a valid time associated with them
ReqTime bool `json:"req_time,omitempty"`
// ReqLoc is specified if notes stored in this notefile must have a valid location associated with them
ReqLoc bool `json:"req_loc,omitempty"`
}
NotefileInfo has parameters about the Notefile
type TowerLocation ¶
type TowerLocation struct {
Name string `json:"n,omitempty"` // name of the location
CountryCode string `json:"c,omitempty"` // country code
TimeZoneID int `json:"z,omitempty"` // timezone id (see tz.go)
OLC string `json:"l,omitempty"` // location
Lat float64 `json:"lat,omitempty"` // latitude
Lon float64 `json:"lon,omitempty"` // longitude
TimeZone string `json:"zone,omitempty"` // timezone name
MCC int `json:"mcc,omitempty"`
MNC int `json:"mnc,omitempty"`
LAC int `json:"lac,omitempty"`
CID int `json:"cid,omitempty"`
}
TowerLocation is the cell tower location structure generated by the tower utility