Documentation ¶
Index ¶
- Constants
- Variables
- func BlockUntilNoRunningGoRoutines()
- func CreateFeedback(err SyncServiceError) (code int, retryInterval int32, reason string)
- func CreateNotificationID(orgID string, objectType string, objectID string, destType string, ...) string
- func GetNotificationID(notification Notification) string
- func GoRoutineEnded()
- func GoRoutineStarted()
- func HashStrings(strings ...string) uint32
- func InitObjectDownloadSemaphore()
- func InitObjectLocks()
- func IsErrorFeedback(code int) bool
- func IsIgnoredRequest(err error) bool
- func IsInvalidRequest(err error) bool
- func IsNotFound(err error) bool
- func IsValidHashAlgorithm(hashAlgorithm string) bool
- func Load(configFileName string) error
- func NeedDataVerification(metaData MetaData) bool
- func ResetGoRoutineCounter()
- func ServiceListContains(serviceList []ServiceID, service ServiceID) bool
- func SetDefaultConfig(config *Config)
- func StringListContains(stringList []string, str string) bool
- func StringListEqual(sList1 []string, sList2 []string) bool
- func ValidateConfig() error
- func VersionAsString() string
- type ACLentry
- type ChunkInfo
- type Config
- type ConsumedObject
- type DBHealthStatusInfo
- type Destination
- type DestinationRequestInQueue
- type DestinationsStatus
- type HealthStatusInfo
- func (hs *HealthStatusInfo) ClientRequestReceived()
- func (hs *HealthStatusInfo) DBReadFailed()
- func (hs *HealthStatusInfo) DBWriteFailed()
- func (hs *HealthStatusInfo) DisconnectedFromBroker()
- func (hs *HealthStatusInfo) DisconnectedFromDatabase()
- func (hs *HealthStatusInfo) GetLastDisconnectFromBrokerDuration() uint64
- func (hs *HealthStatusInfo) GetLastDisconnectFromDBDuration() uint64
- func (hs *HealthStatusInfo) NodeStarted()
- func (hs *HealthStatusInfo) PublishFailed()
- func (hs *HealthStatusInfo) ReconnectedToBroker()
- func (hs *HealthStatusInfo) ReconnectedToDatabase()
- func (hs *HealthStatusInfo) SubscribeFailed()
- func (hs *HealthStatusInfo) UpdateHealthInfo(details bool, registeredESS uint32, storedObjects uint32)
- type IOError
- type IgnoredRequest
- type InternalError
- type InvalidRequest
- type Locks
- func (locks *Locks) ConditionalLock(index uint32, lockedIndex uint32)
- func (locks *Locks) ConditionalUnlock(index uint32, lockedIndex uint32)
- func (locks *Locks) Lock(index uint32)
- func (locks *Locks) RLock(index uint32)
- func (locks *Locks) RUnlock(index uint32)
- func (locks *Locks) Unlock(index uint32)
- type MQTTHealthStatusInfo
- type MessagingGroup
- type MetaData
- type NotFound
- type Notification
- type NotificationInfo
- type ObjectDestinationPolicy
- type ObjectInQueue
- type ObjectInVerifyQueue
- type ObjectStatus
- type Organization
- type PathError
- type Policy
- type PolicyProperty
- type SecurityError
- type SemVer
- type SemVerRange
- type ServiceID
- type SetupError
- type StoreDestinationStatus
- type StoredOrganization
- type SyncServiceError
- func CreateError(err error, message string) SyncServiceError
- func GetHash(hashAlgo string) (hash.Hash, crypto.Hash, SyncServiceError)
- func GetStartAndEndRangeFromContentRangeHeader(request *http.Request) (int64, int64, int64, SyncServiceError)
- func GetStartAndEndRangeFromRangeHeader(request *http.Request) (int64, int64, SyncServiceError)
- func ValidateDestinationListInput(destinationsList []string) (bool, SyncServiceError)
- type SyncServiceVersion
- type UsageInfo
Constants ¶
const ( // status at sender side NotReadyToSend = "notReady" // The object is not ready to be sent to the other side Verifying = "verifying" // The object data is in the process of verification VerificationFailed = "verificationFailed" // The data verification is failed ReadyToSend = "ready" // The object is ready to be sent to the other side // status at receiver side PartiallyReceived = "partiallyreceived" // Received the object from the other side, waiting for its data ReceiverVerifying = "receiverVerifying" // The object data at receiver side is in the process of verification ReceiverVerificationFailed = "receiverVerificationFailed" // The data verification is failed at receiver side CompletelyReceived = "completelyReceived" // The object was received completely from the other side ObjConsumed = "objconsumed" // The object was consumed by the app ObjDeleted = "objdeleted" // The object was deleted by the other side ObjReceived = "objreceived" // The object was received by the app ConsumedByDest = "consumedByDest" // The object was consumed by the other side (ESS only) )
Object status
const ( Update = "update" Updated = "updated" HandleUpdate = "handleUpdate" Consumed = "consumed" AckConsumed = "ackconsumed" ConsumedByDestination = "consumedByDest" Getdata = "getdata" Data = "data" UpdatePending = "updatePending" ConsumedPending = "consumedPending" Delete = "delete" DeletePending = "deletePending" Deleted = "deleted" DeletedPending = "deletedPending" AckDelete = "ackDelete" AckDeleted = "ackDeleted" Resend = "resend" AckResend = "ackresend" Register = "register" AckRegister = "regack" RegisterNew = "registerNew" RegisterAsNew = "registerAsNew" Unregister = "unregister" Received = "received" ReceivedPending = "receivedpending" AckReceived = "ackreceived" ReceivedByDestination = "receivedByDest" Feedback = "feedback" Error = "error" Ping = "ping" ReceiverError = "receiverError" )
Notification status and type
const ( Pending = "pending" Delivering = "delivering" Delivered = "delivered" )
Indication whether the object has been delivered to the destination
const ( InternalErrorCode = 1 IOErrorCode = 2 SecurityErrorCode = 3 PathErrorCode = 4 InvalidObject = 5 )
Feedback codes
const ( DestinationsACLType = "destinations" ObjectsACLType = "objects" )
Types of various ACLs
const ( AddAction = "add" RemoveAction = "remove" RegisterAction = "register" DeleteAction = "delete" )
API payload actions
const ( TypeDestination = "destination" TypeObject = "object" )
NotificationType of object sent to objectWorkQueue
const ( ResendAll = iota ResendDelivered ResendUndelivered )
Resend flag options
const ( Bolt = "bolt" InMemory = "inmemory" Mongo = "mongo" )
Storage providers
const ( Sha1 = "SHA1" Sha256 = "SHA256" )
Hash Algorithms supported for digital signature
const ( CSS = "CSS" ESS = "ESS" )
Cloud Sync Service or Edge Sync Service
const ( ListeningBoth = "both" ListeningSecurely = "secure" ListeningUnsecurely = "unsecure" ListeningUnix = "unix" ListeningSecureUnix = "secure-unix" )
Listening types
const ( MQTTProtocol = "mqtt" HTTPProtocol = "http" HybridMQTT = "hybrid-mqtt" HybridWIoTP = "hybrid-wiotp" WIoTP = "wiotp" )
Protocol definitions
const ( ParallelMQTTNone = "none" ParallelMQTTSmall = "small" ParallelMQTTMedium = "medium" ParallelMQTTLarge = "large" )
The parallelism modes by which incoming MQTT messages are processed
const ( Red = "red" Yellow = "yellow" Green = "green" )
Health status values
const DefaultLogTraceFileSize = 20000
DefaultLogTraceFileSize default value for log and trace file size in KB
const MANIFEST_OBJECT_TYPE = "agent_upgrade_manifests"
const Magic = uint32(0x01010101)
Magic is a magic number placed in the front of various payloads
Variables ¶
var HTTPCSSURL string
HTTPCSSURL specifies the CSS URL for HTTP communication from ESS
var IsInvalidDescription = regexp.MustCompile(`<[/]?[a-zA-Z0-9]+>`).MatchString
IsInvalidDescription checks if metadata description text contains XSS tags in this format: <abc> or </abc>
var IsValidName = regexp.MustCompile(`^[a-zA-Z0-9|!|@|#|$|^|*|\-|_|.|~|\pL|\pN]+$`).MatchString
IsValidName checks if the string only contains letters, digits, and !@#%^*-_.~
var ObjectDownloadSemaphore *semaphore.Weighted
ObjectDownloadSemaphore sets the concurrent spi object download concurrency
var Registered bool
Registered indicates if this node, an ESS, has registered itself
var ResendAcked bool
ResendAcked indicates if the resend objects request had been acknowledged
var Running bool
Running indicates that the Sync Service is running
var ServingAPIs bool
ServingAPIs when true, indicates that the Sync Service is serving the various APIs over HTTP
var SingleOrgCSS bool
SingleOrgCSS is true in case of CSS ouside WIoTP with one organization set in the configration, and false otherwise
Functions ¶
func BlockUntilNoRunningGoRoutines ¶
func BlockUntilNoRunningGoRoutines()
BlockUntilNoRunningGoRoutines blocks the current "thread"
func CreateFeedback ¶
func CreateFeedback(err SyncServiceError) (code int, retryInterval int32, reason string)
CreateFeedback extracts feedback parameters from an error
func CreateNotificationID ¶
func CreateNotificationID(orgID string, objectType string, objectID string, destType string, destID string) string
CreateNotificationID creates notification ID
func GetNotificationID ¶
func GetNotificationID(notification Notification) string
GetNotificationID gets the notification ID for the notification
func InitObjectDownloadSemaphore ¶ added in v1.6.8
func InitObjectDownloadSemaphore()
InitObjectDownloadSemaphore initializes ObjectDownloadSemaphore
func IsErrorFeedback ¶
IsErrorFeedback returns true if the feedback code corresponds to an error
func IsIgnoredRequest ¶ added in v1.6.8
IsInvalidRequest returns true if the error passed in is the common.InvalidRequest error
func IsInvalidRequest ¶
IsInvalidRequest returns true if the error passed in is the common.InvalidRequest error
func IsNotFound ¶
IsNotFound returns true if the error passed in is the common.NotFound error
func IsValidHashAlgorithm ¶ added in v1.6.4
func NeedDataVerification ¶ added in v1.6.8
func ResetGoRoutineCounter ¶
func ResetGoRoutineCounter()
ResetGoRoutineCounter sets the go routines counter to 0
func ServiceListContains ¶
ServiceListContains returns true if serviceIDList contains the given serviceID
func SetDefaultConfig ¶
func SetDefaultConfig(config *Config)
SetDefaultConfig sets the default configuration into the provided Config struct
func StringListContains ¶ added in v0.10.12
StringListContains returns true if string list contains given string
func StringListEqual ¶ added in v1.8.4
StringListEqual returns true if sList1 and sList2 contain same strings
func VersionAsString ¶
func VersionAsString() string
VersionAsString returns the current version as string
Types ¶
type ChunkInfo ¶
type ChunkInfo struct {
ResendTime int64 `json:"resendTime" bson:"resend-time"`
}
ChunkInfo describes chunks for multi-inflight data transfer. swagger:ignore
type Config ¶
type Config struct { // NodeType specifies whether this node is a CSS or ESS NodeType string `env:"NODE_TYPE"` // DestinationType specifies the destination type of this node DestinationType string `env:"DESTINATION_TYPE"` // DestinationID specifies the destination id of this node DestinationID string `config:"DestinationId" env:"DESTINATION_ID"` // OrgID specifies the organization ID of this node OrgID string `config:"OrgId" env:"ORG_ID"` // ListeningType specifies whether or the server is // listening securely, unsecurely, both securely and unsecurely, using Unix sockets, // or using Unix sockets securely. // Possible values are secure, unsecure, both, unix, secure-unix. // unix and secure-unix can only be specified if the NodeType is ESS. // Defaults to unsecure on a CSS and secure on an ESS ListeningType string `env:"LISTENING_TYPE"` // ListeningAddress specifies the address to listen on // If the ListeningType is unix or secure-unix, this property specifies the socket file to be used. // The file will be erased and recreated, if it already exists. The filename is relative // to the PersistenceRootPath configuration property if it doesn't start with a slash (/). ListeningAddress string `env:"LISTENING_ADDRESS"` // SecureListeningPort specifies the port to listen on for HTTPS SecureListeningPort uint16 `env:"SECURE_LISTENING_PORT"` // UnsecureListeningPort specifies the port the CSS listens on for HTTP UnsecureListeningPort uint16 `env:"UNSECURE_LISTENING_PORT"` // ServerCertificate specifies the Server side certificate to use to serve as HTTPS. // This value can either be the certificate itself or the path of a file containing // the certificate. If it is a path of a file, then it is relative to the // PersistenceRootPath configuration property if it doesn't start with a slash (/). ServerCertificate string `env:"SERVER_CERTIFICATE"` // ServerKey specifies the Server side key to use to serve as HTTPS. // This value can either be the key itself or the path of a file containing the key. // If it is a path of a file, then it is relative to the PersistenceRootPath configuration // property if it doesn't start with a slash (/). ServerKey string `env:"SERVER_KEY"` // CSSOnWIoTP indicates whether the CSS is inside or outside the WIoTP. // The default value is false, i.e. outside. CSSOnWIoTP bool `env:"CSS_ON_WIOTP"` // UsingEdgeConnector indicates whether or not the ESS should connect to the Watson IoT Platform via an Edge Connector. // Not relevant to the CSS. // The default value is false. UsingEdgeConnector bool `env:"USING_EDGE_CONNECTOR"` // LeadershipTimeout is the timeout for leadership updates in seconds LeadershipTimeout int32 `env:"LEADERSHIP_TIMEOUT"` // AuthenticationHandler indicates which Authentication handler should be used. // The current possible values are: // dummy - for the dummyAuthenticate Authentication handler AuthenticationHandler string `env:"AUTHENTICATION_HANDLER"` // Buffer size of Object Queue to send objects for notification handling // For the CSS, default value is 1000 // For the ESS, default value is 2 ObjectQueueBufferSize uint64 `env:"OBJECT_QUEUE_BUFFER_SIZE"` // Buffer size of Object Queue to verify object data // Default size is 500 VerifyQueueBufferSize uint64 `env:"VERIFY_QUEUE_BUFFER_SIZE"` // CommunicationProtocol is a comma separated list of protocols to be used for communication between CSS and ESS // The elements of the list can be 'http', 'mqtt', and 'wiotp' // wiotp indicates MQTT communication via the Watson IoT Platform and mqtt indicates direct MQTT communication to a broker // The list must not include both wiotp and mqtt (only one mode of MQTT communication is allowed) // For ESS only a single protocol is allowed // The default is mqtt CommunicationProtocol string `env:"COMMUNICATION_PROTOCOL"` // MQTTClientID contains the client id MQTTClientID string `config:"MQTTClientId" env:"MQTT_CLIENT_ID"` // MQTTUserName contains the MQTT user name MQTTUserName string `env:"MQTT_USER_NAME"` // MQTTPassword contains the MQTT password MQTTPassword string `env:"MQTT_PASSWORD"` // MQTTUseSSL specifies whether or not to use SSL connection with the broker MQTTUseSSL bool `env:"MQTT_USE_SSL"` // MQTTCACertificate specifies the CA certificate that was used to sign the server certificates // used by the MQTT broker. This value can either be the CA certificate itself or the path of a file // containing the CA certificate. If it is a path of a file, then it is relative to the // PersistenceRootPath configuration property if it doesn't start with a slash (/). // Default value: broker/ca/ca.cert.pem MQTTCACertificate string `env:"MQTT_CA_CERTIFICATE"` // MQTTSSLCert specifies the SSL client certificate of the X509 key pair used to communicate with // the MQTT broker. This value can either be the certificate itself or the path of a file containing // the certificate. If it is a path of a file, then it is relative to the // PersistenceRootPath configuration property if it doesn't start with a slash (/). MQTTSSLCert string `env:"MQTT_SSL_CERT"` // MQTTSSLKey specifies the SSL client key of the X509 key pair used to communicate with the // MQTT broker. This value can either be the key itself or the path of a file containing the // key. If it is a path of a file, then it is relative to the // PersistenceRootPath configuration property if it doesn't start with a slash (/). MQTTSSLKey string `env:"MQTT_SSL_KEY"` // MQTTAllowInvalidCertificates specifies that the MQTT client will not attempt to validate the server certificates // Please only set this for development purposes! It makes using TLS pointless and is never the right answer. // Defaults to false MQTTAllowInvalidCertificates bool `env:"MQTT_ALLOW_INVALID_CERTIFICATES"` // MQTTBrokerConnectTimeout specifies the timeout (in seconds) of attempts to connect to the MQTT broker on startup // Default value 300 MQTTBrokerConnectTimeout int `env:"MQTT_BROKER_CONNECT_TIMEOUT"` // MQTTParallelMode specifies the parallelism mode by which incoming MQTT messages are processed // Possible values: "none", "small", "medium", "large" // Default is "none" (or empty string), i.e., no threading MQTTParallelMode string `env:"PARALLEL_MQTT_MODE"` // Root path for storing persisted data. // Default value: /var/wiotp-edge/persist PersistenceRootPath string `env:"PERSISTENCE_ROOT_PATH"` // BrokerAddress specifies the address to connect to for the MQTT broker or // a list of server URIs for environments with multiple MQTT brokers BrokerAddress string `env:"BROKER_ADDRESS"` // BrokerPort specifies the port to connect to for the MQTT broker BrokerPort uint16 `env:"BROKER_PORT"` // HTTPPollingInterval specifies the frequency in seconds of ESS HTTP polling for updates HTTPPollingInterval uint16 `env:"HTTP_POLLING_INTERVAL"` // HTTPCSSHost specifies the CSS host for HTTP communication from ESS HTTPCSSHost string `env:"HTTP_CSS_HOST"` // HTTPCSSPort specifies the CSS host for HTTP communication from ESS HTTPCSSPort uint16 `env:"HTTP_CSS_PORT"` // HTTPCSSUseSSL specifies whether or not to use SSL connection with the CSS HTTPCSSUseSSL bool `env:"HTTP_CSS_USE_SSL"` // HTTPCSSCACertificate specifies the CA certificate that was used to sign the server certificate // used by the CSS. This value can either be the CA certificate itself or the path of a file containing // the CA certificate. If it is a path of a file, then it is relative to the // PersistenceRootPath configuration property if it doesn't start with a slash (/). // Default value: none HTTPCSSCACertificate string `env:"HTTP_CSS_CA_CERTIFICATE"` // HTTPESSClientTimeout is to specify the http client timeout in seconds for ESS // default is 120s HTTPESSClientTimeout int `env:"HTTPESSClientTimeout"` // HTTPESSObjClientTimeout is to specify the http client timeout for downloading models (or objects) in seconds for ESS // default is 600s HTTPESSObjClientTimeout int `env:"HTTPESSObjClientTimeout"` // HTTPCSSObjDownloadConcurrencyMultiplier specifies a number to multiple the number of threads by to set allowed concurrent downloads per CSS // default is 1 HTTPCSSObjDownloadConcurrencyMultiplier int `env:"HTTPCSSObjDownloadConcurrencyMultiplier"` // LogLevel specifies the logging level in string format LogLevel string `env:"LOG_LEVEL"` // LogRootPath specifies the root path for the log files LogRootPath string `env:"LOG_ROOT_PATH"` // LogTraceDestination is a comma separated list of destinations for the logging and tracing // The elements of the list can be `file`, `stdout`, `syslog`, and 'glog' // 'glog' is golang/glog logger LogTraceDestination string `env:"LOG_TRACE_DESTINATION"` // LogFileName specifies the name of the log file LogFileName string `env:"LOG_FILE_NAME"` // TraceLevel specifies the tracing level in string form TraceLevel string `env:"TRACE_LEVEL"` // TraceRootPath specifies the root path for the trace files TraceRootPath string `env:"TRACE_ROOT_PATH"` // TraceFileName specifies the name of the trace file TraceFileName string `env:"TRACE_FILE_NAME"` // Maximal size of a trace/log file in kilo bytes. LogTraceFileSizeKB int `env:"LOG_TRACE_FILE_SIZE_KB"` // The limit on the number of compressed files of trace/log. MaxCompressedlLogTraceFilesNumber int `env:"MAX_COMPRESSED_LOG_TRACE_FILES_NUMBER"` // LogTraceMaintenanceInterval specifies the frequency in seconds of log and trace maintenance (memory consumption, etc.) LogTraceMaintenanceInterval int16 `env:"LOG_TRACE_MAINTENANCE_INTERVAL"` // ResendInterval specifies the frequency in seconds of checks to resend unacknowledged notifications // ESS resends register notification with this interval // Other notifications are resent with frequency equal to ResendInterval*6 ResendInterval int16 `env:"RESEND_INTERVAL"` // ESSCallSPIRetryInterval specifies the frequence in seconds of resend failed updated notifications. // Default is 2s ESSCallSPIRetryInterval int32 `env:"ESS_CALL_SPI_RETRY_INTERVAL"` // ESSSPIMaxRetry specifies the number of retry if ESS receives notification transparent error ESSSPIMaxRetry int `env:"ESSSPIMaxRetry"` // ESSPingInterval specifies the frequency in hours of ping messages that ESS sends to CSS ESSPingInterval int16 `env:"ESS_PING_INTERVAL"` // RemoveESSRegistrationTime specifies the time period in days after which the CSS // removes an inactive ESS. Any pending records and operations for the ESS are removed. // CSS only parameter, ignored on ESS // A value of zero means ESSs are never removed RemoveESSRegistrationTime int16 `env:"REMOVE_ESS_REGISTRATION_TIME"` // EnableDataChunk specifies whether or not to transfer data in chunks between CSS and ESS // It is always true for MQTT EnableDataChunk bool `env:"ENABLE_DATA_CHUNK"` // Maximum size of data that can be sent in one message MaxDataChunkSize int `env:"MAX_DATA_CHUNK_SIZE"` // Max num of inflight chunks MaxInflightChunks int `env:"MAX_INFLIGHT_CHUNKS"` // MongoAddressCsv specifies one or more addresses of the mongo database MongoAddressCsv string `env:"MONGO_ADDRESS_CSV"` // MongoAuthDbName specifies the name of the database used to establish credentials and privileges MongoAuthDbName string `env:"MONGO_AUTH_DB_NAME"` // MongoDbName specifies the name of the database to use MongoDbName string `env:"MONGO_DB_NAME"` // MongoUsername specifies the username of the mongo database MongoUsername string `env:"MONGO_USERNAME"` // MongoPassword specifies the username of the mongo database MongoPassword string `env:"MONGO_PASSWORD"` // MongoUseSSL specifies whether or not to use SSL connection with mongo MongoUseSSL bool `env:"MONGO_USE_SSL"` // MongoCACertificate specifies the CA certificate that was used to sign the server certificate // used by the MongoDB server. This value can either be the CA certificate itself or the path of a // file containing the CA certificate. If it is a path of a file, then it is relative to the // PersistenceRootPath configuration property if it doesn't start with a slash (/). MongoCACertificate string `env:"MONGO_CA_CERTIFICATE"` // MongoAllowInvalidCertificates specifies that the mongo driver will not attempt to validate the server certificates. // Please only set this for development purposes! It makes using TLS pointless and is never the right answer. MongoAllowInvalidCertificates bool `env:"MONGO_ALLOW_INVALID_CERTIFICATES"` // MongoSessionCacheSize specifies the number of MongoDB session copies to use MongoSessionCacheSize int `env:"MONGO_SESSION_CACHE_SIZE"` // MongoSleepTimeBetweenRetry specifies the time in milliseconds between each retry of updating data in mongodb MongoSleepTimeBetweenRetry int `env:"MONGO_SLEEP_TIME_BETWEEN_RETRY"` // DatabaseConnectTimeout specifies that the timeout in seconds of database connection attempts on startup // The default value is 300 DatabaseConnectTimeout int `env:"DATABASE_CONNECT_TIMEOUT"` // StorageMaintenanceInterval specifies the frequency in seconds of storage checks (for expired objects, etc.) StorageMaintenanceInterval int16 `env:"STORAGE_MAINTENANCE_INTERVAL"` // ObjectActivationInterval specifies the frequency in seconds of checking if there are inactive objects // that are ready to be activated ObjectActivationInterval int16 `env:"OBJECT_ACTIVATION_INTERVAL"` // StorageProvider specifies the type of the storage to be used by this node. // For the CSS the options are 'mongo' (the default), and 'bolt' // For the ESS the options are 'inmemory' (the default), and 'bolt' StorageProvider string `env:"STORAGE_PROVIDER"` // ESSConsumedObjectsKept specifies the number of objects sent by the ESS and consumed by the CSS // that are kept by the ESS for reporting // The default value is 1000 ESSConsumedObjectsKept int `env:"ESS_CONSUMED_OBJECTS_KEPT"` // MessagingGroupCacheExpiration specifies the expiration time in minutes of organization to messaging group mapping cache MessagingGroupCacheExpiration int16 `env:"MESSAGING_GROUP_CACHE_EXPIRATION"` // ShutdownQuiesceTime specifies the maximum time in seconds that the Sync Service will wait for internal tasks to end while shuting down // The default values is 60 seconds ShutdownQuiesceTime int `env:"SHUTDOWN_QUIESCE_TIME"` // ObjectsDataPath specifies a directory in which the object's data should be persisted. // The application can then access the object's data directly on the file system instead of reading // the data via the Sync Service. Applications should only read/copy the data but not modify/delete it. // When ObjectsDataPath is set the DestinationDataURI field in the object's metadata includes // the full path to the object's data. // ObjectsDataPath can be used only when the StorageProvider is set to bolt. // The default is empty (not set) meaning that the object's data is persisted internally in a // path selected by the Sync Service. ObjectsDataPath string `env:"OBJECTS_DATA_PATH"` }
Config contains the parsed contents of the configuration file
var Configuration Config
Configuration contains the read in configuration
type ConsumedObject ¶
ConsumedObject contains consumed object's meta data and its timestamp
type DBHealthStatusInfo ¶
type DBHealthStatusInfo struct { DBStatus string `json:"dbStatus"` DisconnectedFromDB bool `json:"disconnectedFromDB"` LastDisconnectFromDBDuration uint64 `json:"lastDisconnectFromDBDuration,omitempty"` DBReadFailures uint32 `json:"dbReadFailures"` DBWriteFailures uint32 `json:"dbWriteFailures"` TimeSinceLastReadWriteError uint64 `json:"timeSinceLastReadWriteError,omitempty"` // contains filtered or unexported fields }
DBHealthStatusInfo describes the health status of the database of the sync-service node swagger:model
var DBHealth DBHealthStatusInfo
DBHealth describes the health status of the database of the sync-service node
type Destination ¶
type Destination struct { // DestOrgID is the destination organization ID // Each sync service object belongs to a single organization DestOrgID string `json:"destinationOrgID" bson:"destination-org-id"` // DestType is the destination type // required: true DestType string `json:"destinationType" bson:"destination-type"` // DestID is the destination ID // required: true DestID string `json:"destinationID" bson:"destination-id"` // Communication is the communication protocol used by the destination to connect (can be MQTT or HTTP) // required: true // enum: HTTP,MQTT Communication string `json:"communication" bson:"communication"` // CodeVersion is the sync service code version used by the destination // required: true CodeVersion string `json:"codeVersion" bson:"code-version"` }
Destination describes a sync service node. Each sync service edge node (ESS) has an address that is composed of the node's ID, Type, and Organization. An ESS node communicates with the CSS using either MQTT or HTTP. swagger:model
type DestinationRequestInQueue ¶ added in v1.6.7
type DestinationRequestInQueue struct { Action string Status string Object MetaData Destination Destination }
type DestinationsStatus ¶
type DestinationsStatus struct { // DestType is the destination type // required: true DestType string `json:"destinationType"` // DestID is the destination ID // required: true DestID string `json:"destinationID"` // Status is the destination status // required: true // enum: pending,delivering,delivered,consumed,deleted,error Status string `json:"status"` // Message is the message for the destination // required: false Message string `json:"message"` }
DestinationsStatus describes the delivery status of an object for a destination DestinationsStatus provides information about the delivery status of an object for a certain destination. The status can be one of the following: Indication whether the object has been delivered to the destination
pending - inidicates that the object is pending delivery to this destination delivering - indicates that the object is being delivered to this destination delivered - indicates that the object was delivered to this destination consumed - indicates that the object was consumed by this destination deleted - indicates that this destination acknowledged the deletion of the object error - indicates that a feedback error message was received from this destination
swagger:model
type HealthStatusInfo ¶
type HealthStatusInfo struct { NodeType string `json:"nodeType"` HealthStatus string `json:"healthStatus"` UpTime uint64 `json:"upTime"` // contains filtered or unexported fields }
HealthStatusInfo describes the health status of the sync-service node swagger:model
var HealthStatus HealthStatusInfo
HealthStatus describes the health status of the sync-service node
func (*HealthStatusInfo) ClientRequestReceived ¶
func (hs *HealthStatusInfo) ClientRequestReceived()
ClientRequestReceived increments the client requests counter
func (*HealthStatusInfo) DBReadFailed ¶
func (hs *HealthStatusInfo) DBReadFailed()
DBReadFailed increments the database read failures counter
func (*HealthStatusInfo) DBWriteFailed ¶
func (hs *HealthStatusInfo) DBWriteFailed()
DBWriteFailed increments the database read failures counter
func (*HealthStatusInfo) DisconnectedFromBroker ¶
func (hs *HealthStatusInfo) DisconnectedFromBroker()
DisconnectedFromBroker sets the DisconnectedFromMQTTBroker to true and the disconnectFromBrokerStartTime to current time
func (*HealthStatusInfo) DisconnectedFromDatabase ¶
func (hs *HealthStatusInfo) DisconnectedFromDatabase()
DisconnectedFromDatabase sets the DisconnectedFromDB to true and the disconnectFromDBStartTime to current time
func (*HealthStatusInfo) GetLastDisconnectFromBrokerDuration ¶
func (hs *HealthStatusInfo) GetLastDisconnectFromBrokerDuration() uint64
GetLastDisconnectFromBrokerDuration returns the duration of the last disconnect from the MQTT broker In case the node is currently disconnected, LastDisconnectFromBrokerDuration will be 0, and this function has to be called to calculated the duration of the current disconnect.
func (*HealthStatusInfo) GetLastDisconnectFromDBDuration ¶
func (hs *HealthStatusInfo) GetLastDisconnectFromDBDuration() uint64
GetLastDisconnectFromDBDuration returns the duration of the last disconnect from the database In case the node is currently disconnected, LastDisconnectFromDBDuration will be 0, and this function has to be called to calculated the duration of the current disconnect.
func (*HealthStatusInfo) NodeStarted ¶
func (hs *HealthStatusInfo) NodeStarted()
NodeStarted is called when the node starts
func (*HealthStatusInfo) PublishFailed ¶
func (hs *HealthStatusInfo) PublishFailed()
PublishFailed increments the publish failures counter
func (*HealthStatusInfo) ReconnectedToBroker ¶
func (hs *HealthStatusInfo) ReconnectedToBroker()
ReconnectedToBroker sets the DisconnectedFromMQTTBroker to false and calculates LastDisconnectFromBrokerDuration
func (*HealthStatusInfo) ReconnectedToDatabase ¶
func (hs *HealthStatusInfo) ReconnectedToDatabase()
ReconnectedToDatabase sets the DisconnectedFromDB to false and the disconnectFromBrokerStartTime to current time
func (*HealthStatusInfo) SubscribeFailed ¶
func (hs *HealthStatusInfo) SubscribeFailed()
SubscribeFailed increments the subscription failures counter
func (*HealthStatusInfo) UpdateHealthInfo ¶
func (hs *HealthStatusInfo) UpdateHealthInfo(details bool, registeredESS uint32, storedObjects uint32)
UpdateHealthInfo updates the current health status of the sync service node
type IOError ¶
type IOError struct {
Message string
}
IOError is the error for requests failed because of the IO
type IgnoredRequest ¶ added in v1.6.8
type IgnoredRequest struct {
Message string
}
InvalidRequest is the error for invalid reguests swagger:ignore
func (*IgnoredRequest) Error ¶ added in v1.6.8
func (e *IgnoredRequest) Error() string
type InternalError ¶
type InternalError struct {
Message string
}
InternalError is a general error
func (*InternalError) Error ¶
func (e *InternalError) Error() string
type InvalidRequest ¶
type InvalidRequest struct {
Message string
}
InvalidRequest is the error for invalid reguests swagger:ignore
func (*InvalidRequest) Error ¶
func (e *InvalidRequest) Error() string
type Locks ¶
type Locks struct {
// contains filtered or unexported fields
}
Locks is a set of object locks
var ObjectLocks Locks
ObjectLocks are locks for object and notification changes
func (*Locks) ConditionalLock ¶
ConditionalLock locks the object if the index doesn't correspond to a lock that is already taken
func (*Locks) ConditionalUnlock ¶
ConditionalUnlock unlocks the object if the index doesn't correspond to a lock that is already taken
type MQTTHealthStatusInfo ¶
type MQTTHealthStatusInfo struct { MQTTConnectionStatus string `json:"mqttConnectionStatus"` SubscribeFailures uint32 `json:"subscribeFailures"` PublishFailures uint32 `json:"publishFailures"` DisconnectedFromMQTTBroker bool `json:"disconnectedFromMQTTBroker"` LastDisconnectFromBrokerDuration uint64 `json:"lastDisconnectFromBrokerDuration,omitempty"` TimeSinceLastSubscribeError uint64 `json:"timeSinceLastSubscribeError,omitempty"` TimeSinceLastPublishError uint64 `json:"timeSinceLastPublishError,omitempty"` // contains filtered or unexported fields }
MQTTHealthStatusInfo describes the health status of the MQTT connection of the sync-service node swagger:model
var MQTTHealth MQTTHealthStatusInfo
MQTTHealth describes the health status of the MQTT connection of the sync-service node
type MessagingGroup ¶
MessagingGroup maps organization to its messaging group
type MetaData ¶
type MetaData struct { // ObjectID is a unique identifier of the object // required: true ObjectID string `json:"objectID" bson:"object-id"` // ObjectType is the type of the object. // The type is used to group multiple objects, for example when checking for object updates. // required: true ObjectType string `json:"objectType" bson:"object-type"` // DestOrgID is the organization ID of the object (an object belongs to exactly one organization). // This field is ignored when working with ESS (the ESS's orgID is used). DestOrgID string `json:"destinationOrgID" bson:"destination-org-id"` // DestID is the ID of the destination. If omitted the object is sent to all ESSs with the same DestType. // This field is ignored when working with ESS (the destination is the CSS). DestID string `json:"destinationID" bson:"destination-id"` // DestType is the type of destination to send the object to. // If omitted (and if DestinationsList is omitted too) the object is broadcasted to all known destinations. // This field is ignored when working with ESS (the destination is always the CSS). DestType string `json:"destinationType" bson:"destination-type"` // DestinationsList is the list of destinations as type:id pairs to send the object to. // When a DestinationsList is provided DestType and DestID must be omitted. // This field is ignored when working with ESS (the destination is always the CSS). DestinationsList []string `json:"destinationsList" bson:"destinations-list"` // DestinationPolicy is the policy specification that should be used to distribute this object // to the appropriate set of destinations. // When a DestinationPolicy is provided DestinationsList, DestType, and DestID must be omitted. DestinationPolicy *Policy `json:"destinationPolicy" bson:"destination-policy"` // Expiration is a timestamp/date indicating when the object expires. // When the object expires it is automatically deleted. // The timestamp should be provided in RFC3339 format. // This field is available only when working with the CSS. // Optional field, if omitted the object doesn't expire. Expiration string `json:"expiration" bson:"expiration"` // Version is the object's version (as used by the application). // Optional field, empty by default. Version string `json:"version" bson:"version"` // Description is a textual description of the object. // Optional field, empty by default. Description string `json:"description" bson:"description"` // Link is a link to where the data for this object can be fetched from. // The link is set and used by the application. The sync service does not access the link. // Optional field, if omitted the data must be provided by the application. Link string `json:"link" bson:"link"` // Inactive is a flag indicating that this object is inactive for now. // An object can be created as inactive which means it is not delivered to its destination. The object can be activated later. // Optional field, default is false (object active). Inactive bool `json:"inactive" bson:"inactive"` // ActivationTime is a timestamp/date as to when this object should automatically be activated. // The timestamp should be provided in RFC3339 format. // Optional field, if omitted (and Inactive is true) the object is never automatically activated. ActivationTime string `json:"activationTime" bson:"activation-time"` // NoData is a flag indicating that there is no data for this object. // Objects with no data can be used, for example, to send notifications. // Optional field, default is false (object includes data). NoData bool `json:"noData" bson:"no-data"` // MetaOnly is a flag that indicates that this update is only of the metadata. The current object's data is left unchanged. // Optional field, default is false (both data and metadata are updated). MetaOnly bool `json:"metaOnly" bson:"meta-only"` // DestinationDataURI is a URI indicating where the receiver of the object should store it. // Currently only file URIs are supported. // This field is available only when working with the CSS. // Optional field, if omitted the object is stored in the node's internal storage. DestinationDataURI string `json:"destinationDataUri" bson:"data-uri"` // SourceDataURI is a URI indicating where the sender of the object should read the data from. // Currently only file URIs are supported. // This field is available only when working with the ESS. // Optional field, if omitted the object's data should be provided by the user. SourceDataURI string `json:"sourceDataUri" bson:"source-data-uri"` // ExpectedConsumers is the number of applications that are expected to indicate that they have consumed the object. // Optional field, default is 1. ExpectedConsumers int `json:"consumers" bson:"consumers"` // AutoDelete is a flag indicating whether to delete the object after it is delivered to all its destinations from the DestinationsList. // Optional field, default is false (do not delete). // This field is used only when working with the CSS. Objects are always deleted after delivery on the ESS. AutoDelete bool `json:"autodelete" bson:"autodelete"` // OriginID is the ID of origin of the object. Set by the internal code. // Read only field, should not be set by users. OriginID string `json:"originID" bson:"origin-id"` // OriginType is the type of origin of the object. Set by the internal code. // Read only field, should not be set by users. OriginType string `json:"originType" bson:"origin-type"` // Deleted is a flag indicating to applications polling for updates that this object has been deleted. // Read only field, should not be set by users. Deleted bool `json:"deleted" bson:"deleted"` // InstanceID is an internal instance ID. // This field should not be set by users. InstanceID int64 `json:"instanceID" bson:"instance-id"` // DataID is an internal data ID. // This field should not be set by users. DataID int64 `json:"dataID" bson:"data-id"` // ObjectSize is an internal field indicating the size of the object's data. // This field should not be set by users. ObjectSize int64 `json:"objectSize" bson:"object-size"` // ChunkSize is an internal field indicating the maximal message payload size. // This field should not be set by users. ChunkSize int `json:"chunkSize" bson:"chunk-size"` // UploadChunkSize is an internal field indicating the upload chunk size used when uploading the // the model (if chunking was used) // This field should not be set by users. UploadChunkSize int64 `json:"uploadChunkSize" bson:"upload-chunk-size"` // HashAlgorithm used for data signature sign/verification. "SHA1" and "SHA256" are supported hash algorithms. // Valid values are: "SHA1", "SHA256" // Optional field, if omitted the data signature/verification will not be applied HashAlgorithm string `json:"hashAlgorithm" bson:"hash-algorithm"` // PublicKey is a base64 encoded string. It is the publicKey to verify the data of the object // Optional field, if omitted the data will not be verified with public key and signature PublicKey string `json:"publicKey" bson:"public-key"` // Signature is a base64 encoded string. It is the data signature to verify data of the object // Optional field, if omitted the data will not be verified with public key and signature Signature string `json:"signature" bson:"signature"` // Public is a flag indicate this object is visiable to all users in all orgs // Optional field, default is false (not visiable to all users) Public bool `json:"public" bson:"public"` // OwnerID is an internal field indicating who creates the object // This field should not be set by users OwnerID string `json:"ownerID" bson:"owner-id"` }
MetaData is the metadata that identifies and defines the sync service object. Every object includes metadata (mandatory) and data (optional). The metadata and data can be updated independently. Each sync service node (ESS) has an address that is composed of the node's ID, Type, and Organization. To send an object to a single node set the destinationType and destinationID fields to match the node's Type and ID. To send an object to all the nodes of a certain type set destinationType to the appropriate type and leave destinationID empty. If both destinationType and destinationID are empty the object is sent to all nodes. swagger:model
type NotFound ¶
type NotFound struct {
// contains filtered or unexported fields
}
NotFound is the error returned if an object wasn't found
type Notification ¶
type Notification struct { ObjectID string `json:"objectID" bson:"object-id"` ObjectType string `json:"objectType" bson:"object-type"` DestOrgID string `json:"destinationOrgID" bson:"destination-org-id"` DestID string `json:"destinationID" bson:"destination-id"` DestType string `json:"destinationType" bson:"destination-type"` Status string `json:"status" bson:"status"` InstanceID int64 `json:"instanceID" bson:"instance-id"` DataID int64 `json:"dataID" bson:"data-id"` ResendTime int64 `json:"resendTime" bson:"resend-time"` }
Notification is used to store notifications in the store swagger:ignore
type NotificationInfo ¶
type NotificationInfo struct { NotificationTopic string DestType string DestID string InstanceID int64 DataID int64 MetaData *MetaData }
NotificationInfo contains information about a message to send to the other side
type ObjectDestinationPolicy ¶
type ObjectDestinationPolicy struct { // OrgID is the organization ID of the object (an object belongs to exactly one organization). // required: true OrgID string `json:"orgID"` // ObjectType is the type of the object. // The type is used to group multiple objects, for example when checking for object updates. // required: true ObjectType string `json:"objectType"` // ObjectID is a unique identifier of the object // required: true ObjectID string `json:"objectID"` // DestinationPolicy is the policy specification that should be used to distribute this object // to the appropriate set of destinations. DestinationPolicy *Policy `json:"destinationPolicy,omitempty"` // Destinations is the list of the object's current destinations Destinations []DestinationsStatus `json:"destinations"` }
ObjectDestinationPolicy contains information about an object that has a Destination Policy. swagger:model
type ObjectInQueue ¶ added in v1.6.7
type ObjectInQueue struct { NotificationAction string // Notification status and type NotificationType string Object MetaData Destinations []StoreDestinationStatus //use this list if NotificationType is common.TypeDestination }
type ObjectInVerifyQueue ¶ added in v1.6.8
type ObjectInVerifyQueue struct {
Object MetaData
}
type ObjectStatus ¶
type ObjectStatus struct { // OrgID is the organization ID of the organization OrgID string `json:"orgID"` // ObjectType is the object type // required: true ObjectType string `json:"objectType"` // ObjectID is the object ID // required: true ObjectID string `json:"objectID"` // Status is the object status for this destination // required: true // enum: delivering,delivered,consumed,deleted,error Status string `json:"status"` }
ObjectStatus describes the delivery status of an object for a destination The status can be one of the following: Indication whether the object has been delivered to the destination
delivering - indicates that the object is being delivered delivered - indicates that the object was delivered consumed - indicates that the object was consumed deleted - indicates that this destination acknowledged the deletion of the object error - indicates that a feedback error message was received
swagger:model
type Organization ¶
type Organization struct { // OrgID is the organization ID of the organization OrgID string `json:"orgID" bson:"org-id"` // User is the user name to be used when connecting to this organization User string `json:"user" bson:"user"` // Password is the password to be used when connecting to this organization Password string `json:"password" bson:"password"` // Address is the broker address to be used when connecting to this organization Address string `json:"address" bson:"address"` }
Organization contains organization's information swagger:model
type Policy ¶
type Policy struct { // Properties is the set of properties for a particular policy Properties []PolicyProperty `json:"properties" bson:"properties"` // Constraints is a set of expressions that form the constraints for the policy Constraints []string `json:"constraints" bson:"constraints"` // Services is the list of services this object has affinity for Services []ServiceID `json:"services" bson:"services"` // Timestamp indicates when the policy was last updated (result of time.Now().UTC().UnixNano()) Timestamp int64 `json:"timestamp" bson:"timestamp"` }
Policy describes a policy made up of a set of properties and constraints swagger:model
type PolicyProperty ¶
type PolicyProperty struct { // Name is the name of the property // required: true Name string `json:"name" bson:"name"` // Value is the value of the property // required: true Value interface{} `json:"value" bson:"value"` // Type is the type of the property. // It is only required where the system can't interpret the value correctly by context. // required: false Type string `json:"type" bson:"type"` }
PolicyProperty is a property in a policy swagger:model
type SecurityError ¶
type SecurityError struct {
Message string
}
SecurityError is the error for requests failed because of security
func (*SecurityError) Error ¶
func (e *SecurityError) Error() string
type SemVer ¶
SemVer represents a semantic version
func ParseSemVer ¶
ParseSemVer parses a semantic version string and returns a SemVer
type SemVerRange ¶
type SemVerRange struct {
// contains filtered or unexported fields
}
SemVerRange represents a range over semantic version
func ParseSemVerRange ¶
func ParseSemVerRange(input string) (*SemVerRange, error)
ParseSemVerRange parses a semantic version range string and returns a SemVerRange
func (*SemVerRange) IsInRange ¶
func (semVerRange *SemVerRange) IsInRange(semVer *SemVer) bool
IsInRange returns true/false if the SemVer is in the range of the SemVerRange
type ServiceID ¶
type ServiceID struct { // OrgID is the organization ID of the service OrgID string `json:"orgID" bson:"org-id"` // Arch is the architecture of the service Arch string `json:"arch" bson:"arch"` // ServiceName is the name of the service ServiceName string `json:"serviceName" bson:"service-name"` // Version is the version of the service Version string `json:"version" bson:"version"` }
ServiceID contains the ID of a service to which an object may have affinity for swagger:model
func GetRemovedPolicyServices ¶
GetRemovedPolicyServices is the method to compare existing destination policy and new destination policy, returning removed policy services
type SetupError ¶
type SetupError struct {
Message string
}
SetupError is the error for setup issues swagger:ignore
func (*SetupError) Error ¶
func (e *SetupError) Error() string
type StoreDestinationStatus ¶
type StoreDestinationStatus struct { Destination Destination `bson:"destination"` Status string `bson:"status"` Message string `bson:"message"` }
StoreDestinationStatus is the information about destinations and their status for an object swagger:ignore
type StoredOrganization ¶
type StoredOrganization struct { Org Organization Timestamp time.Time }
StoredOrganization contains organization and its update timestamp
type SyncServiceError ¶
type SyncServiceError error
SyncServiceError is a common error type used in the sync service swagger:ignore
func CreateError ¶
func CreateError(err error, message string) SyncServiceError
CreateError creates a sync-service error from a Go error
func GetHash ¶ added in v1.6.2
GetHash returns the hash object and crypto hash algo name (used by rsa.VerifyPSS() func) of specified hash algorithm
func GetStartAndEndRangeFromContentRangeHeader ¶ added in v1.6.8
func GetStartAndEndRangeFromContentRangeHeader(request *http.Request) (int64, int64, int64, SyncServiceError)
Content-Range: bytes 1-2/*\ Returns totalsize, startOffset, endOffset, err
func GetStartAndEndRangeFromRangeHeader ¶ added in v1.6.8
func GetStartAndEndRangeFromRangeHeader(request *http.Request) (int64, int64, SyncServiceError)
func ValidateDestinationListInput ¶
func ValidateDestinationListInput(destinationsList []string) (bool, SyncServiceError)
ValidateDestinationListInput checks if destinationsList contains < or >, to avoid injecting html like tags from user
type SyncServiceVersion ¶
SyncServiceVersion is the current version of the Sync-Service
var Version SyncServiceVersion
Version is the current version of the Sync-Service
type UsageInfo ¶
type UsageInfo struct { ClientRequests uint64 `json:"clientRequests"` RegisteredESS uint32 `json:"registeredESS"` StoredObjects uint32 `json:"storedObjects"` }
UsageInfo describes the usage of the sync-service node swagger:model
var HealthUsageInfo UsageInfo
HealthUsageInfo describes the usage of the sync-service node