Documentation ¶
Overview ¶
Package note errors.go contains programmatically-testable error strings
Index ¶
- Constants
- func BodyToObject(body *map[string]interface{}, object interface{}) (err error)
- func ErrorClean(err error) error
- func ErrorContains(err error, errKeyword string) bool
- func ErrorJSON(message string, err error) (rspJSON []byte)
- func ErrorString(err error) string
- func JSONMarshal(v interface{}) ([]byte, error)
- func JSONMarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func JSONToBody(bodyJSON []byte) (body map[string]interface{}, err error)
- func JSONUnmarshal(data []byte, v interface{}) (err error)
- func ObjectToBody(object interface{}) (body map[string]interface{}, err error)
- func ObjectToJSON(object interface{}) (bodyJSON []byte, err error)
- func WordToNumber(word string) (num uint, success bool)
- func WordsFromNumber(number uint32) string
- func WordsFromString(in string) (out string)
- func WordsToNumber(words string) (num uint32, found bool)
- type Contact
- type Contacts
- type DeviceSession
- type DeviceUsage
- type Event
- type EventRoutingStatus
- type History
- type Info
- type Message
- type MessageAddress
- type MessageContact
- 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)
- func (note *Note) When() (when int64)
- type NotefileInfo
- type RouteLogEntry
- type TowerLocation
- type Word
Constants ¶
const ACActionAnd = "&"
ACActionAnd ensures that all of these actions are allowed
const ACActionCreate = "create"
ACActionCreate (golint)
const ACActionDelete = "delete"
ACActionDelete (golint)
const ACActionMonitor = "monitor"
ACActionMonitor (golint)
const ACActionOr = "|"
ACActionOr ensures that any of these actions are allowed
const ACActionRead = "read"
ACActionRead (golint)
const ACActionUpdate = "update"
ACActionUpdate (golint)
const ACResourceAccount = "account:"
ACResourceAccount is an account resource, which is the accountUID that always begins with this string
const ACResourceAccounts = "account:*"
ACResourceAccounts is the resource for all accounts and all meta-account-level actions
const ACResourceApp = "app:"
ACResourceApp is the app (project) resource, which is the appUID that always begins with this string
const ACResourceApps = "app:*"
ACResourceApps is the resource for all apps
const ACResourceDevice = "dev:"
ACResourceDevice is the device resource, which is the deviceUID that always begins with this string
const ACResourceDevices = "dev:*"
ACResourceDevices is the resource for all devices
const ACResourceNotecardFirmwares = "notecard:*"
ACResourceNotecardFirmwares is the resource for all notecard firmware
const ACResourceNotefile = "file:"
ACResourceNotefile is the notefile resource and its note-level actions, which is the notefileID prefixed with this string
const ACResourceNotefiles = "file:*"
ACResourceNotefiles is the resource for all notefiles and all meta-notefile-level actions
const ACResourceRoute = "route:"
ACResourceRoute is an route resource, which is the routeUID that always begins with this string
const ACResourceRoutes = "route:*"
ACResourceRoutes is the resource for all routes and all meta-route-level actions
const ACResourceSep = ":"
ACResourceSep is the separator for building compound resource names
const ACResourceUserFirmwares = "firmware:*"
ACResourceUserFirmwares is the resource for all user firmware
const ACValidActionsAccount = "account:create,account:read,account:update,account:delete"
ACValidActionsAccount are actions allowed on accounts
const ACValidActionsApp = "app:create,app:read,app:update,app:delete,app:monitor"
ACValidActionsApp are actions allowed on apps
const ACValidActionsDev = "dev:read,dev:update,dev:delete,dev:monitor"
ACValidActionsDev are actions allowed on devices
const ACValidActionsFile = "file:create,file:read,file:update,file:delete"
ACValidActionsFile are actions allowed on notefiles
const ACValidActionsFirmware = "firmware:create,firmware:read,firmware:update,firmware:delete"
ACValidActionsFirmware are actions allowed on user firmware
const ACValidActionsNotecard = "notecard:create,notecard:read,notecard:update,notecard:delete"
ACValidActionsNotecard are actions allowed on notecard firmware
const ACValidActionsRoute = "route:create,route:read,route:update,route:delete"
ACValidActionsRoute are actions allowed on routes
const ContactOwnerNoteID = "owner"
ContactOwnerNoteID indicates that this is my contact
const ContactStore = "contacts.db"
ContactStore is the place where the user retains contact info
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 ErrAccessDenied = "{access-denied}"
ErrAccessDenied (golint)
const ErrAppDeleted = "{app-deleted}"
ErrAppDeleted (golint)
const ErrAppExists = "{app-exists}"
ErrAppExists (golint)
const ErrAppNotFound = "{app-noexist}"
ErrAppNotFound (golint)
const ErrAppNotSpecified = "{app-none}"
ErrAppNotSpecified (golint)
const ErrAuth = "{auth}"
ErrAuth (golint)
const ErrCardIo = "{io}"
ErrCardIo (golint)
const ErrClosed = "{closed}"
ErrClosed (golint)
const ErrDFUInProgress = "{dfu-in-progress}"
ErrDFUInProgress (golint)
const ErrDFUNotReady = "{dfu-not-ready}"
ErrDFUNotReady (golint)
const ErrDeviceDelay10 = "{device-delay-10}"
ErrDeviceDelay10 (golint)
const ErrDeviceDelay15 = "{device-delay-15}"
ErrDeviceDelay15 (golint)
const ErrDeviceDelay20 = "{device-delay-20}"
ErrDeviceDelay20 (golint)
const ErrDeviceDelay30 = "{device-delay-30}"
ErrDeviceDelay30 (golint)
const ErrDeviceDelay5 = "{device-delay-5}"
ErrDeviceDelay5 (golint)
const ErrDeviceDelay60 = "{device-delay-60}"
ErrDeviceDelay60 (golint)
const ErrDeviceDisabled = "{device-disabled}"
ErrDeviceDisabled (golint)
const ErrDeviceNotFound = "{device-noexist}"
ErrDeviceNotFound (golint)
const ErrDeviceNotSpecified = "{device-none}"
ErrDeviceNotSpecified (golint)
const ErrDoNotRoute = "{do-not-route}"
ErrDoNotRoute (golint)
const ErrExtendedNetworkFailure = "{extended-network-failure}"
ErrExtendedNetworkFailure (golint)
const ErrExtendedServiceFailure = "{extended-service-failure}"
ErrExtendedServiceFailure (golint)
const ErrFileNoExist = "{file-noexist}"
ErrFileNoExist (golint)
const ErrFleetNotFound = "{fleet-noexist}"
ErrFleetNotFound (golint)
const ErrGPSInactive = "{gps-inactive}"
ErrGPSInactive (golint)
const ErrHostUnreachable = "{host-unreachable}"
ErrHostUnreachable (golint)
const ErrHubMode = "{hub-mode}"
ErrHubMode (golint)
const ErrHubNoHandler = "{no-handler}"
ErrHubNoHandler (golint)
const ErrIdle = "{idle}"
ErrIdle (golint)
const ErrIncompatible = "{incompatible}"
ErrIncompatible (golint)
const ErrJson = "{not-json}"
ErrJson (golint)
const ErrNetwork = "{network}"
ErrNetwork (golint)
const ErrNoteExists = "{note-exists}"
ErrNoteExists (golint)
const ErrNoteNoExist = "{note-noexist}"
ErrNoteNoExist (golint)
const ErrNotefileExists = "{notefile-exists}"
ErrNotefileExists (golint)
const ErrNotefileInUse = "{notefile-in-use}"
ErrNotefileInUse (golint)
const ErrNotefileName = "{notefile-bad-name}"
ErrNotefileName (golint)
const ErrNotefileNoExist = "{notefile-noexist}"
ErrNotefileNoExist (golint)
const ErrNotefileQueueDisallowed = "{notefile-queue-disallowed}"
ErrNotefileQueueDisallowed (golint)
const ErrProductNotFound = "{product-noexist}"
ErrProductNotFound (golint)
const ErrProductNotSpecified = "{product-none}"
ErrProductNotSpecified (golint)
const ErrRegistrationFailure = "{registration-failure}"
ErrRegistrationFailure (golint)
const ErrReqNotSupported = "{not-supported}"
ErrReqNotSupported (golint)
const ErrSyntax = "{syntax}"
ErrSyntax (golint)
const ErrTemplateIncompatible = "{template-incompatible}"
ErrTemplateIncompatible (golint)
const ErrTicket = "{ticket}"
ErrTicket (golint)
const ErrTimeout = "{timeout}"
ErrTimeout (golint)
const ErrTooBig = "{too-big}"
ErrTooBig (golint)
const ErrTrackerExists = "{tracker-exists}"
ErrTrackerExists (golint)
const ErrTrackerNoExist = "{tracker-noexist}"
ErrTrackerNoExist (golint)
const ErrTransportConnectFailure = "{connect-failure}"
ErrTransportConnectFailure (golint)
const ErrTransportConnected = "{connected}"
ErrTransportConnected (golint)
const ErrTransportConnectedClosed = "{connected-closed}"
ErrTransportConnectedClosed (golint)
const ErrTransportConnecting = "{connecting}"
ErrTransportConnecting (golint)
const ErrTransportDisconnected = "{disconnected}"
ErrTransportDisconnected (golint)
const ErrTransportWaitData = "{wait-data}"
ErrTransportWaitData (golint)
const ErrTransportWaitGateway = "{wait-gateway}"
ErrTransportWaitGateway (golint)
const ErrTransportWaitModule = "{wait-module}"
ErrTransportWaitModule (golint)
const ErrTransportWaitService = "{wait-service}"
ErrTransportWaitService (golint)
const ErrWebPayload = "{web-payload}"
ErrWebPayload (golint)
const EventAdd = "note.add"
EventAdd (golint)
const EventDelete = "note.delete"
EventDelete (golint)
const EventGeolocation = "device.geolocation"
EventGeolocation (golint)
const EventGet = "get"
EventGet (golint)
const EventNoAction = ""
EventNoAction (golint)
const EventPost = "post"
EventPost (golint)
const EventPut = "put"
EventPut (golint)
const EventSession = "session.begin"
EventSession (golint)
const EventTest = "test"
EventTest (golint)
const EventUpdate = "note.update"
EventUpdate (golint)
const EventWebhook = "webhook"
EventWebhook (golint)
const GeolocationNotefile = "_geolocate.qo"
GeolocationNotefile is the hard-wired notefile that the notehub uses when performing a geolocation
const HealthNotefile = "_health.qo"
HealthNotefile is the hard-wired notefile that the notecard uses for health-related info
const HubDefaultInboundNotefile = "data.qi"
HubDefaultInboundNotefile is the hard-wired default notefile for user data
const HubDefaultOutboundNotefile = "data.qo"
HubDefaultOutboundNotefile is the hard-wired default notefile for user data
const LogNotefile = "_log.qo"
LogNotefile is the hard-wired notefile that the notecard uses for debug logging
const MessageContentASCII = ""
MessageContentASCII is just simple ASCII text
const MessageInbox = "messages.qi"
MessageInbox is the place into which messages are received
const MessageOutbox = "messages.qo"
MessageOutbox is the place from which messages are sent
const MessageSTagReceived = "received"
MessageSTagReceived indicates that this was a received message
const MessageSTagSent = "sent"
MessageSTagSent indicates that this was a sent message
const MessageStore = "messages.db"
MessageStore is the place where the user retains messages
const MessageTagImportant = "important"
MessageTagImportant indicates that the sender feels that this is an important message
const MessageTagUrgent = "urgent"
MessageTagUrgent indicates that the sender feels that this is an urgent message
const NotecardRequestNotefile = "_req.qis"
NotecardRequestNotefile is a special notefile for sending notecard requests
const NotecardResponseNotefile = "_rsp.qos"
NotecardResponseNotefile is a special notefile for sending notecard responses
const SessionNotefile = "_session.qo"
SessionNotefile is the hard-wired notefile that the notehub uses when starting a session
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)
const TrackNotefile = "_track.qo"
TrackNotefile is the hard-wired notefile that the notecard can use for tracking the device
const WebNotefile = "_web.qo"
WebNotefile is the hard-wired notefile that the notehub uses when performing web requests
Variables ¶
This section is empty.
Functions ¶
func BodyToObject ¶ added in v1.2.1
BodyToObject Unmarshals the specified map into an object
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 ErrorJSON ¶ added in v1.3.8
ErrorJSON returns a JSON object with nothing but an error code, and with an optional message
func ErrorString ¶ added in v1.1.21
ErrorString safely returns a string from any error, returning "" for nil
func JSONMarshal ¶ added in v1.2.1
JSONMarshal is the equivalent to the json package's Marshal, however it does not escape HTML sitting inside JSON strings.
func JSONMarshalIndent ¶ added in v1.2.1
JSONMarshalIndent is like Marshal but applies Indent to format the output. Each JSON element in the output will begin on a new line beginning with prefix followed by one or more copies of indent according to the indentation nesting.
func JSONToBody ¶ added in v1.1.1
JSONToBody unmarshals the specified object and returns it as a map[string]interface{}
func JSONUnmarshal ¶ added in v1.2.1
JSONUnmarshal uses JSON Numbers, rather than assuming Floats. This fixes an issue in which, when decoding to an arbitrary interface, the JSON package decodes large numbers (like Unix epoch) into floats.
func ObjectToBody ¶ added in v1.1.1
ObjectToBody Marshals the specified object and returns it as map
func ObjectToJSON ¶ added in v1.1.1
ObjectToJSON Marshals the specified object and returns it as a []byte
func WordToNumber ¶ added in v1.3.7
WordToNumber converts a single word to a number
func WordsFromNumber ¶ added in v1.3.7
WordsFromNumber converts a number to three simple words
func WordsFromString ¶ added in v1.3.7
WordsFromString hashes a string with a 32-bit function and converts it to three simple words
func WordsToNumber ¶ added in v1.3.7
WordsToNumber looks up a number from two or three simple words
Types ¶
type Contact ¶ added in v1.5.1
type Contact struct { Name string `json:"name,omitempty"` Affiliation string `json:"org,omitempty"` Role string `json:"role,omitempty"` Email string `json:"email,omitempty"` }
Contact has the basic contact info structure
NOTE: This structure's underlying storage has been decoupled from the use of the structure in business logic. As such, please share any changes to these structures with cloud services to ensure that storage and testing frameworks are kept in sync with these structures used for business logic
type Contacts ¶ added in v1.5.1
type Contacts struct { Admin *Contact `json:"admin,omitempty"` Tech *Contact `json:"tech,omitempty"` }
Contacts has contact info for this app
NOTE: This structure's underlying storage has been decoupled from the use of the structure in business logic. As such, please share any changes to these structures with cloud services to ensure that storage and testing frameworks are kept in sync with these structures used for business logic
type DeviceSession ¶
type DeviceSession struct { // Session ID that can be mapped to the events created during that session SessionUID string `json:"session,omitempty"` // Log key for this session SessionLogKey string `json:"session_log_key,omitempty"` // Info from the device structure DeviceUID string `json:"device,omitempty"` DeviceSN string `json:"sn,omitempty"` ProductUID string `json:"product,omitempty"` FleetUIDs []string `json:"fleets,omitempty"` // Protocol:IP:port address of the handler serving the session Handler string `json:"handler,omitempty"` // Cell ID where the session originated and quality ("mcc,mnc,lac,cellid") CellID string `json:"cell,omitempty"` // Parameters passed by device as a result of scanning towers/APs ScanResults *[]byte `json:"scan,omitempty"` Triangulate *map[string]interface{} `json:"triangulate,omitempty"` // Network connection information sent by the notecard Rssi int `json:"rssi,omitempty"` Sinr int `json:"sinr,omitempty"` Rsrp int `json:"rsrp,omitempty"` Rsrq int `json:"rsrq,omitempty"` Bars int `json:"bars,omitempty"` Rat string `json:"rat,omitempty"` Bearer string `json:"bearer,omitempty"` Ip string `json:"ip,omitempty"` Bssid string `json:"bssid,omitempty"` Ssid string `json:"ssid,omitempty"` Iccid string `json:"iccid,omitempty"` Apn string `json:"apn,omitempty"` // Last known tower and triangulated location as determined at the start of session Tower TowerLocation `json:"tower,omitempty"` Tri TowerLocation `json:"tri,omitempty"` // Last known capture time of a note routed through this session When int64 `json:"when,omitempty"` // Last known GPS location of a note routed through this 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"` // Flag indicating whether the usage data is based on actual stats from the device IsUsageActual bool `json:"usage_actual,omitempty"` // Physical device info Voltage float64 `json:"voltage,omitempty"` Temp float64 `json:"temp,omitempty"` // Type of session ContinuousSession bool `json:"continuous,omitempty"` TLSSession bool `json:"tls,omitempty"` // For keeping track of when the last work was done for a session LastWorkDone int64 `json:"work,omitempty"` // Number of Events routed EventCount int64 `json:"events,omitempty"` // Motion of the notecard Moved int64 `json:"moved,omitempty"` Orientation string `json:"orientation,omitempty"` // Why a session was triggered Trigger string `json:"trigger,omitempty"` // Last known power stats at start of session HighPowerSecsTotal uint32 `json:"hp_secs_total,omitempty"` HighPowerSecsData uint32 `json:"hp_secs_data,omitempty"` HighPowerSecsGPS uint32 `json:"hp_secs_gps,omitempty"` HighPowerCyclesTotal uint32 `json:"hp_cycles_total,omitempty"` HighPowerCyclesData uint32 `json:"hp_cycles_data,omitempty"` HighPowerCyclesGPS uint32 `json:"hp_cycles_gps,omitempty"` // Total device usage at the beginning of the period ThisPtr *DeviceUsage `json:"this,omitempty"` // Total device usage at the beginning of the next period, whenever it happens to occur NextPtr *DeviceUsage `json:"next,omitempty"` // Usage during the period - initially estimated, but then corrected when we get to the next period PeriodPtr *DeviceUsage `json:"period,omitempty"` }
DeviceSession is the basic unit of recorded device usage history
func (*DeviceSession) Next ¶
func (s *DeviceSession) Next() *DeviceUsage
func (*DeviceSession) Period ¶
func (s *DeviceSession) Period() *DeviceUsage
func (*DeviceSession) This ¶
func (s *DeviceSession) This() *DeviceUsage
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"` RcvdBytesSecondary uint32 `json:"bytes_rcvd_secondary,omitempty"` SentBytesSecondary uint32 `json:"bytes_sent_secondary,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 { EventUID string `json:"event,omitempty"` SessionUID string `json:"session,omitempty"` TLS bool `json:"tls,omitempty"` Continuous bool `json:"continuous,omitempty"` BestID string `json:"best_id,omitempty"` DeviceUID string `json:"device,omitempty"` DeviceSN string `json:"sn,omitempty"` ProductUID string `json:"product,omitempty"` AppUID string `json:"app,omitempty"` EndpointID string `json:"endpoint,omitempty"` Received float64 `json:"received,omitempty"` Req string `json:"req,omitempty"` Error string `json:"err,omitempty"` When int64 `json:"when,omitempty"` NotefileID string `json:"file,omitempty"` NoteID string `json:"note,omitempty"` Updates int32 `json:"updates,omitempty"` Deleted bool `json:"deleted,omitempty"` Sent bool `json:"queued,omitempty"` Bulk bool `json:"bulk,omitempty"` Body *map[string]interface{} `json:"body,omitempty"` Payload []byte `json:"payload,omitempty"` // This field is ONLY used when we remove the payload for storage reasons, to show the app how large it was MissingPayloadLength int64 `json:"payload_length,omitempty"` // Location BestLocationType string `json:"best_location_type,omitempty"` BestLocationWhen int64 `json:"best_location_when,omitempty"` BestLat float64 `json:"best_lat,omitempty"` BestLon float64 `json:"best_lon,omitempty"` BestLocation string `json:"best_location,omitempty"` BestCountry string `json:"best_country,omitempty"` BestTimeZone string `json:"best_timezone,omitempty"` Where string `json:"where_olc,omitempty"` WhereWhen int64 `json:"where_when,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"` TowerWhen int64 `json:"tower_when,omitempty"` TowerLat float64 `json:"tower_lat,omitempty"` TowerLon float64 `json:"tower_lon,omitempty"` TowerCountry string `json:"tower_country,omitempty"` TowerLocation string `json:"tower_location,omitempty"` TowerTimeZone string `json:"tower_timezone,omitempty"` TowerID string `json:"tower_id,omitempty"` TriWhen int64 `json:"tri_when,omitempty"` TriLat float64 `json:"tri_lat,omitempty"` TriLon float64 `json:"tri_lon,omitempty"` TriLocation string `json:"tri_location,omitempty"` TriCountry string `json:"tri_country,omitempty"` TriTimeZone string `json:"tri_timezone,omitempty"` TriPoints int32 `json:"tri_points,omitempty"` // Motion Moved int64 `json:"moved,omitempty"` Orientation string `json:"orientation,omitempty"` // Signal strength/quality of the cell Rssi int `json:"rssi,omitempty"` Sinr int `json:"sinr,omitempty"` Rsrp int `json:"rsrp,omitempty"` Rsrq int `json:"rsrq,omitempty"` Rat string `json:"rat,omitempty"` Bars uint32 `json:"bars,omitempty"` // Physical device info Voltage float64 `json:"voltage,omitempty"` Temp float64 `json:"temp,omitempty"` // Triangulation Triangulate *map[string]interface{} `json:"triangulate,omitempty"` // "Routed" environment variables beginning with a "$" prefix Env *map[string]string `json:"environment,omitempty"` Status EventRoutingStatus `json:"status,omitempty"` FleetUIDs *[]string `json:"fleets,omitempty"` // Extended details for routed events. This is not referenced in the source // code because it gets optionally populated by a JSONata transform. It was // added to support the v1 API /v1/projects/<UID>/webhooks/<UID> Details *map[string]interface{} `json:"details,omitempty"` }
Event is the request structure passed to the Notification proc
NOTE: This structure's underlying storage has been decoupled from the use of the structure in business logic. As such, please share any changes to these structures with cloud services to ensure that storage and testing frameworks are kept in sync with these structures used for business logic
type EventRoutingStatus ¶ added in v1.7.1
type EventRoutingStatus string
const ( EventStatusEmpty EventRoutingStatus = "" EventStatusSuccess EventRoutingStatus = "success" EventStatusFailure EventRoutingStatus = "failure" EventStatusInProgress EventRoutingStatus = "in_progress" )
func GetAggregateEventStatus ¶ added in v1.6.11
func GetAggregateEventStatus(logs []RouteLogEntry) EventRoutingStatus
GetAggregateEventStatus returns the status of the event given all of the route logs for the event.
The aggregate status is determined by taking the most recent status for each route. If any of these are failures then the overall status is EventStatusFailure, otherwise it's EventStatusSuccess
type History ¶
type History struct { When int64 `json:"w,omitempty"` Where string `json:"l,omitempty"` WhereWhen int64 `json:"m,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 { NoteID string `json:"id,omitempty"` Body *map[string]interface{} `json:"body,omitempty"` Payload *[]byte `json:"payload,omitempty"` Deleted bool `json:"deleted,omitempty"` }
Info is a general "content" structure
type Message ¶ added in v1.2.1
type Message struct { UID string `json:"id,omitempty"` Sent uint32 `json:"sent,omitempty"` Received uint32 `json:"received,omitempty"` From MessageContact `json:"from,omitempty"` To []MessageContact `json:"to,omitempty"` Tags []string `json:"tags,omitempty"` StoreTags []string `json:"stags,omitempty"` ContentType string `json:"type,omitempty"` Content string `json:"content,omitempty"` Body *map[string]interface{} `json:"body,omitempty"` }
Message is the core message data structure. Note that when stored in a map or a note, the UID is not present but rather is the map key or noteID.
type MessageAddress ¶ added in v1.2.1
type MessageAddress struct { Hub string `json:"hub,omitempty"` ProductUID string `json:"product,omitempty"` DeviceUID string `json:"device,omitempty"` DeviceSN string `json:"sn,omitempty"` Active uint32 `json:"active,omitempty"` }
MessageAddress is the network routing information for a message
type MessageContact ¶ added in v1.2.1
type MessageContact struct { Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` StoreTags []string `json:"stags,omitempty"` Addresses []MessageAddress `json:"addresses,omitempty"` }
MessageContact is the entity sending a message, who may have multiple devices/addresses
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"` Tower *TowerLocation `json:"T,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"` // The count of total notes in this notefile. This is used in the Req API, but not in the Notebox info Total int `json:"total,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"` // AnonAddAllowed is specified if anyone is allowed to drop into this notefile without authentication AnonAddAllowed bool `json:"anon_add,omitempty"` // ImportTime is the epoch time of when an external data source (such as a feed) last sync'ed data inbound ImportTime int64 `json:"import_time,omitempty"` // ExportTime is the epoch time of when an external data source (such as a feed) last sync'ed data outbound ExportTime int64 `json:"export_time,omitempty"` }
NotefileInfo has parameters about the Notefile
type RouteLogEntry ¶ added in v1.5.1
type RouteLogEntry struct { EventSerial int64 `json:"event,omitempty"` RouteSerial int64 `json:"route,omitempty"` Date time.Time `json:"date,omitempty"` Attn bool `json:"attn,omitempty"` Status string `json:"status,omitempty"` Text string `json:"text,omitempty"` URL string `json:"url,omitempty"` }
RouteLogEntry is the log entry used by notification processing
type TowerLocation ¶
type TowerLocation struct { When int64 `json:"time,omitempty"` // time when this location was ascertained Name string `json:"n,omitempty"` // name of the location CountryCode string `json:"c,omitempty"` // country code 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"` OLC string `json:"l,omitempty"` // open location code TimeZoneID int `json:"z,omitempty"` // timezone id (see tz.go) Count int64 `json:"count,omitempty"` // number of times this location was recently used Towers int `json:"towers,omitempty"` // number of triangulation points }
TowerLocation is the cell tower location structure generated by the tower utility