Skip to content

finEdge2Cloud ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793423013/FIN+5.3.1+finEdge2Cloud 中文整理基于 FIN 5.3.1

导读: 本页为 finEdge2Cloud 的 API 参考文档。

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • mixins
  • classes
  • Slot Details
    • getTopic
    • make
    • onMessage
    • MAX_RETRY_COUNT
    • cancel
    • completeDateTime
    • errorMessage
    • file
    • id
    • isAborted
    • isAwaitingRetry
    • isCancelled
    • isCompleted
    • isExpired
    • isSucceeded
    • onBackupMessage
    • progress
    • retries
    • rolling
    • run
    • setResponseTimeout
    • setRetryDelay
    • setUpload
    • start
    • startDateTime
    • toDict
    • validateBackupPath
    • getCertificateSigningRequest
    • getDeviceId
    • getKeyId
    • getKeyStore
    • getKeyStorePassword
    • getNotBeforeCertificateDate
    • hasCertificate
    • hasCsrBeenGenerated
    • reset
    • saveCertificate
    • setDeviceId
    • allTasks
    • backup
    • getTask
    • connect
    • disconnect
    • getServerPort
    • isConnected
    • publish
    • subscribe
    • totalPublishedMessages
    • totalSubscribed
    • totalSubscribedMessages
    • totalUnsubscribed
    • unsubscribe
    • allBackupTasks
    • createPermanentBackup
    • createRollingBackup
    • createTunnel
    • deletedAsync
    • disconnectAsync
    • findService
    • getBackupTask
    • getDiagnostics
    • getLog
    • isDeviceDeleted
    • isMaintOutOfDate
    • onStart
    • onStop
    • refreshMaintStatus
    • registerAsync
    • requestProcessor
    • resetDeviceRegistration
    • resetPreConnectRetryCount
    • setConnected
    • syncDevice
    • unregisterAsync
    • checkSyncDevice
    • cleanupTunnelledConnections
    • getMessageHandlers
    • register
    • unregister
    • canSyncProj
    • encodeDevice
    • encodeProject
    • encodeSite
    • visitDevice
    • visitProject
    • visitSite
    • checkSync
    • lastDeviceSync
    • syncAll
    • syncSites
    • totalDeviceSyncs
    • chunkFileToHttpPut
    • finEdge2CloudAllBackupTasks
    • finEdge2CloudApp
    • finEdge2CloudBackupTask
    • finEdge2CloudCancelBackupTask
    • finEdge2CloudCreatePermanentBackup
    • finEdge2CloudCreatePermanentBackupSync
    • finEdge2CloudCreateRollingBackup
    • finEdge2CloudCreateRollingBackupSync
    • finEdge2CloudDiagnostics
    • finEdge2CloudDiagnosticsForm
    • finEdge2CloudIsConnected
    • finEdge2CloudResetDeviceRegistration
    • finEdge2CloudSettings
    • finEdge2CloudSyncDevice
    • finHttpGet
    • finHttpPost
    • finHttpPut
    • api
    • lib
    • preAuthenticate
    • settings
    • web
    • applyUserTagsFunc
    • mod
    • onService
  • …(其余标题见英文正文)

API 正文(英文) ​

| MessagePublishVisitor | A device sync visitor that encodes and publishes messages. | | MockCertificateRepository | A mock certificate repository for unit testing | | MockConnectionDataStore | A mock connection data store for unit testing | | MockHttpProxyReqProcessor | A mock HTTP proxy request processor for testing. | | MockMessageHandler | A mock message handler for unit testing | | MockMessageQueue | A mock message queue used for testing | | MockTunnel | A mock tunnel. | | MockTunnelFactory | A mock factory for creating tunnels. | | MockWebServiceClient | A mock web service client for unit testing | | PingMessageHandler | A simple ping message handler that responds with the system's current date and time. | | PropsUtil | Utility methods for accessing configuration properties | | ReqResMessageHandler | A message handler for processing request/response style messages from a headend system. | | SiteChangedVisitor | A visitor that only publishes site information if the site record has changed. | | TestFileUploadHandler | Unit tests that map to Java unit tests. | | TunnelDirector | Manages tunnelled connections for remote access. | | TunnelFactoryImpl | A factory implementation that creates an instance of a tunnel. | | TunnelMessageHandler | A message that opens a tunnelled connection for remote access. | | Util | Edge 2 Cloud utility methods. | | WsJavaTunnel | A tunnelled remote connection using a Java WebSocket. | | WsJavaTunnelWrapper | Wraps a java web socket tunnel so a message queue can be injected. | | WsTunnel | A tunnelled remote connection that uses a Fantom WebSocket. |


BackupMessageHandler ​

const class BackupMessageHandler : Obj, MessageHandler

Handler for all back up client messages.

Constructors

make

Methods

getTopic
onMessage

Slot Details ​


getTopic ​

virtual override Str getTopic(MessageContext cx)


make ​

new make(CloudConnectionService? service, Log log, |->Bool| isMaintExpired := |->Bool| { ... })


onMessage ​

virtual override Void onMessage(Str topic, Buf reqBuf, MessageQueue mq, MessageContext cx)


BackupTask ​

const class BackupTask : Obj

Uploads a backup to Edge2Cloud.

Constructors

make

Fields

MAX_RETRY_COUNTThe maximum number of retries before aborting the upload.
fileThe file being backed up.
idThe unique id for the current backup task.
rollingIs the backup rolling or permanent.
startDateTimeThe date time the task started.

Methods

cancelManually abort the upload.
completeDateTimeThe date time when the task completed or null if it hasn't completed yet.
errorMessageReturns the error message for the backup.
isAbortedReturn true if the task is aborted.
isAwaitingRetryReturn true if the task is waiting to retry uploading a chunk.
isCancelledReturn true if the task was cancelled.
isCompletedReturn true if the task is completed.
isExpiredReturn true if the task is expired and can be removed.
isSucceededReturn true if the task succeeded.
onBackupMessageCallback used when there's a response to a message.
progressReturns the progress of the backup task as a percentage.
retriesReturn the total number of retries made for this backup task.
runRuns the backup task.
setResponseTimeoutSet a new response timeout.
setRetryDelaySet a new retry delay timeout.
setUploadSet a new upload handler.
startStart a new backup task and return it.
toDictReturn the backup task as a dict.
validateBackupPathValidate the backup file path.

Slot Details ​


MAX_RETRY_COUNT ​

const static Int MAX_RETRY_COUNT := 60

The maximum number of retries before aborting the upload.


cancel ​

Void cancel()

Manually abort the upload.


completeDateTime ​

DateTime? completeDateTime()

The date time when the task completed or null if it hasn't completed yet.


errorMessage ​

Str errorMessage()

Returns the error message for the backup.


file ​

const File file

The file being backed up.


id ​

const Str id

The unique id for the current backup task.


isAborted ​

Bool isAborted()

Return true if the task is aborted.


isAwaitingRetry ​

Bool isAwaitingRetry()

Return true if the task is waiting to retry uploading a chunk.


isCancelled ​

Bool isCancelled()

Return true if the task was cancelled.


isCompleted ​

Bool isCompleted()

Return true if the task is completed.


isExpired ​

Bool isExpired()

Return true if the task is expired and can be removed.


isSucceeded ​

Bool isSucceeded()

Return true if the task succeeded.


make ​

new make(File file, Bool rolling, MessageQueue mq, MessageContext cx, Log log, ActorPool pool)


onBackupMessage ​

Void onBackupMessage(Str:Str data)

Callback used when there's a response to a message.


progress ​

Int progress()

Returns the progress of the backup task as a percentage.


retries ​

Int retries()

Return the total number of retries made for this backup task.


rolling ​

const Bool rolling

Is the backup rolling or permanent.


run ​

Void run()

Runs the backup task.

Fantom encourages use of the Actor model whereby this would be normally split up into many different messages. For this use case, it would make the code far more difficult to follow. Hence the simple large task on a single thread approach.


setResponseTimeout ​

Void setResponseTimeout(Duration responseTimeout)

Set a new response timeout.


setRetryDelay ​

Void setRetryDelay(Duration retryDelay)

Set a new retry delay timeout.


setUpload ​

Void setUpload(|File,|Int->Str|,|Int|->Str[]| upload)

Set a new upload handler.


start ​

static BackupTask start(File file, Bool rolling, MessageQueue mq, MessageContext cx, Log log)

Start a new backup task and return it.


startDateTime ​

const DateTime startDateTime

The date time the task started.


toDict ​

Dict toDict()

Return the backup task as a dict.


validateBackupPath ​

static Void validateBackupPath(Uri path)

Validate the backup file path.

Throw an error if the backup file path is invalid.


CertificateRepository ​

mixin CertificateRepository

Stores certificate and key related information.

Methods

getCertificateSigningRequestReturns the certificate signing request.
getDeviceIdGet the device id.
getKeyIdReturns an id for the public key.
getKeyStoreReturns the underlying Java keystore.
getKeyStorePasswordReturns the underlying Java keystore's password.
getNotBeforeCertificateDateReturn the not before date time in an ISO 8601 date time format.
hasCertificateReturns try if the certificate is available.
hasCsrBeenGeneratedReturns true if the CSR has been generated at least once.
resetReset all information in the keystore.
saveCertificateSave the certificate to the repository.
setDeviceIdSet the device id.

Slot Details ​


getCertificateSigningRequest ​

abstract Str getCertificateSigningRequest(Str hostId)

Returns the certificate signing request.


getDeviceId ​

abstract Str getDeviceId()

Get the device id.


getKeyId ​

abstract Str getKeyId()

Returns an id for the public key.


getKeyStore ​

abstract KeyStore getKeyStore()

Returns the underlying Java keystore.


getKeyStorePassword ​

abstract Str getKeyStorePassword()

Returns the underlying Java keystore's password.


getNotBeforeCertificateDate ​

abstract Str getNotBeforeCertificateDate()

Return the not before date time in an ISO 8601 date time format.


hasCertificate ​

abstract Bool hasCertificate()

Returns try if the certificate is available.


hasCsrBeenGenerated ​

abstract Bool hasCsrBeenGenerated()

Returns true if the CSR has been generated at least once.


reset ​

abstract Void reset()

Reset all information in the keystore.


saveCertificate ​

abstract Void saveCertificate(Str certificate)

Save the certificate to the repository.


setDeviceId ​

abstract Void setDeviceId(Str deviceId)

Set the device id.


CloudBackupDirector ​

class CloudBackupDirector : Obj

Uploads backups to Edge2Cloud.

Constructors

make

Methods

allTasksReturn all the existing tasks.
backupStart a cloud backup.
getTaskReturn the task for the specified id or null if it can't be found.
onBackupMessageForward the backup response messages to any running tasks.

Slot Details ​


allTasks ​

BackupTask[] allTasks()

Return all the existing tasks.


backup ​

BackupTask backup(File file, Bool rolling, MessageQueue mq, MessageContext cx)

Start a cloud backup.


getTask ​

BackupTask? getTask(Str id)

Return the task for the specified id or null if it can't be found.


make ​

new make(Log log)


onBackupMessage ​

Void onBackupMessage(Str:Str data)

Forward the backup response messages to any running tasks.


CloudCertificateRepository ​

class CloudCertificateRepository : Obj, CertificateRepository

Stores certificate and key related information.

Please see the comments in CloudCertificateStore regarding why we need to provide an additional wrapper.

Constructors

make

Methods

getCertificateSigningRequest
getDeviceId
getKeyId
getKeyStore
getKeyStorePassword
getNotBeforeCertificateDate
hasCertificate
hasCsrBeenGenerated
reset
saveCertificate
setDeviceId

Slot Details ​


getCertificateSigningRequest ​

virtual override Str getCertificateSigningRequest(Str hostId)


getDeviceId ​

virtual override Str getDeviceId()


getKeyId ​

virtual override Str getKeyId()


getKeyStore ​

virtual override KeyStore getKeyStore()


getKeyStorePassword ​

virtual override Str getKeyStorePassword()


getNotBeforeCertificateDate ​

virtual override Str getNotBeforeCertificateDate()


hasCertificate ​

virtual override Bool hasCertificate()


hasCsrBeenGenerated ​

virtual override Bool hasCsrBeenGenerated()


make ​

new make(File configDir)


reset ​

virtual override Void reset()


saveCertificate ​

virtual override Void saveCertificate(Str certificate)


setDeviceId ​

virtual override Void setDeviceId(Str deviceId)


CloudCertificateStore ​

class CloudCertificateStore : Obj

Stores certificate and key related information.

Please note, ideally this class should implement CertificateRepository but Fantom doesn't seem to support that with native classes. This class can implement a mixin but casting it to the mixin type causes a runtime error.

Constructors

make

Methods

getCertificateSigningRequest
getDeviceId
getKeyId
getKeyStore
getKeyStorePassword
getNotBeforeCertificateDate
hasCertificate
hasCsrBeenGenerated
reset
saveCertificate
setDeviceId

Slot Details ​


getCertificateSigningRequest ​

Str getCertificateSigningRequest(Str hostId)


getDeviceId ​

Str getDeviceId()


getKeyId ​

Str getKeyId()


getKeyStore ​

KeyStore getKeyStore()


getKeyStorePassword ​

Str getKeyStorePassword()


getNotBeforeCertificateDate ​

Str getNotBeforeCertificateDate()


hasCertificate ​

Bool hasCertificate()


hasCsrBeenGenerated ​

Bool hasCsrBeenGenerated()


make ​

new make(File configDir)


reset ​

Void reset()


saveCertificate ​

Void saveCertificate(Str certificate)


setDeviceId ​

Void setDeviceId(Str deviceId)


CloudClient ​

class CloudClient : Obj

CloudClient native implementation

Please note, ideally this class should implement MessageQueue but Fantom doesn't seem to support that with native classes. This class can implement a mixin but casting it to the mixin type causes a runtime error.

Constructors

make

Methods

connect
disconnect
getServerPort
isConnected
publish
subscribe
totalPublishedMessages
totalSubscribed
totalSubscribedMessages
totalUnsubscribed
unsubscribe

Slot Details ​


connect ​

Void connect()


disconnect ​

Void disconnect()


getServerPort ​

Int getServerPort()


isConnected ​

Bool isConnected()


make ​

new make(Str clientEndPoint, Str clientId, KeyStore keyStore, Str keyStorePassword, Int timeout, Int keepAliveInterval, |Bool| connectionStatusChangeListener)


publish ​

Void publish(Str topic, Buf payload)


subscribe ​

Void subscribe(Str topic, |Str,Buf| subscribeCallback)


totalPublishedMessages ​

Int totalPublishedMessages()


totalSubscribed ​

Int totalSubscribed()


totalSubscribedMessages ​

Int totalSubscribedMessages()


totalUnsubscribed ​

Int totalUnsubscribed()


unsubscribe ​

Void unsubscribe(Str topic)


CloudConnectionService ​

const class CloudConnectionService : Obj, Service, ConnectionDataStore

Manages a connection to the Edge 2 Cloud Cloud Services.

Constructors

make

Fields

requestProcessor

Methods

allBackupTasks
createPermanentBackup
createRollingBackup
createTunnel
deletedAsyncAsynchronously signal this device has been deleted from the Cloud.
disconnectAsyncAsynchronoulsy disconnect from the Cloud service.
findService
getBackupTask
getCertificateSigningRequest
getDiagnostics
getLog
hasCertificate
isConnected
isDeviceDeleted
isMaintOutOfDateReturn true if the maintenance is out of date.
onBackupMessage
onStart
onStop
refreshMaintStatusRefresh the cached maintenance status by re-evaluating the license list.
registerAsyncAsynchronously register the message handlers with the service.
resetDeviceRegistration
resetPreConnectRetryCount
setConnected
syncDevice
unregisterAsyncAsynchronously unregister the message handlers with the service.

Slot Details ​


allBackupTasks ​

static BackupTask[] allBackupTasks()


createPermanentBackup ​

static BackupTask createPermanentBackup(File file)


createRollingBackup ​

static BackupTask createRollingBackup(File file)


createTunnel ​

Void createTunnel(Uri uri, Str:Str headers, Str deviceId, Str host, Str org, Str env)


deletedAsync ​

Future deletedAsync()

Asynchronously signal this device has been deleted from the Cloud.


disconnectAsync ​

Future disconnectAsync()

Asynchronoulsy disconnect from the Cloud service.


findService ​

static CloudConnectionService? findService()


getBackupTask ​

static BackupTask? getBackupTask(Str id)


getCertificateSigningRequest ​

static Str getCertificateSigningRequest()


getDiagnostics ​

static [Str:Obj]? getDiagnostics()


getLog ​

static Log getLog()


hasCertificate ​

static Bool hasCertificate()


isConnected ​

static Bool isConnected()


isDeviceDeleted ​

static Bool isDeviceDeleted()


isMaintOutOfDate ​

static Bool isMaintOutOfDate()

Return true if the maintenance is out of date. Uses a cached value updated by the periodic check and after license renewal. Returns false if the service is not running.


make ​

new make(Sys sys, Log log, HttpProxyReqProcessor? requestProcessor := null)


onBackupMessage ​

Void onBackupMessage(Str:Str data)


onStart ​

virtual override Void onStart()


onStop ​

virtual override Void onStop()


refreshMaintStatus ​

static Void refreshMaintStatus()

Refresh the cached maintenance status by re-evaluating the license list. Called periodically by checkMaint (on the service Actor) and immediately after a license update (on the web thread). Thread-safe: AtomicBool write, const Sys read, and StackHubLic.list() is safe to call from any thread.


registerAsync ​

Future registerAsync(MessageHandler[] messageHandlers)

Asynchronously register the message handlers with the service. The message handlers are registered when the returned future has successfully completed.


requestProcessor ​

const HttpProxyReqProcessor requestProcessor


resetDeviceRegistration ​

static Void resetDeviceRegistration()


resetPreConnectRetryCount ​

static Void resetPreConnectRetryCount()


setConnected ​

virtual override Void setConnected(Bool connected)


syncDevice ​

static Void syncDevice()


unregisterAsync ​

Future unregisterAsync(MessageHandler[] messageHandlers)

Asynchronously unregister the message handlers with the service. The message handlers are unregistered when the returned future has successfully completed.


CloudMessageQueue ​

class CloudMessageQueue : Obj, MessageQueue

A message queue that connects to a remote cloud service.

Please see the comments in CloudClient regarding why we need to provide an additional wrapper.

Constructors

make

Methods

connect
disconnect
getServerPort
publish
subscribe
totalPublishedMessages
totalSubscribed
totalSubscribedMessages
totalUnsubscribed
unsubscribe

Slot Details ​


connect ​

virtual override Void connect(MessageContext cx)


disconnect ​

virtual override Void disconnect()


getServerPort ​

virtual override Int getServerPort()


make ​

new make(CertificateRepository certRepo, |Bool| connectionStatusChangeListener)


publish ​

virtual override Void publish(Str topic, Buf payload)


subscribe ​

virtual override Void subscribe(Str topic, |Str,Buf| subscribeCallback)


totalPublishedMessages ​

virtual override Int totalPublishedMessages()


totalSubscribed ​

virtual override Int totalSubscribed()


totalSubscribedMessages ​

virtual override Int totalSubscribedMessages()


totalUnsubscribed ​

virtual override Int totalUnsubscribed()


unsubscribe ​

virtual override Void unsubscribe(Str topic)


ConnectionDataStore ​

mixin ConnectionDataStore

Stores connection information.

Methods

setConnectedWrite whether we are successfully connected

Slot Details ​


setConnected ​

abstract Void setConnected(Bool connected)

Write whether we are successfully connected


ConnectionDirector ​

class ConnectionDirector : Obj

Directs the workflow for the main outgoing connection. This class manages the connection state machine.

Constructors

make

Methods

allBackupTasks
checkSyncDeviceChecks whether the device needs to be synchronized or not.
cleanupTunnelledConnections
connect
createPermanentBackup
createRollingBackup
createTunnel
disconnect
getBackupTask
getCertificateSigningRequestReturn the certificate signing request.
getDiagnostics
getMessageHandlers
hasCertificateReturn true if the certificate is available.
onBackupMessage
register
resetDeviceRegistrationReset the device registration.
resetPreConnectRetryCountReset the pre-connect retry count will mean retries will be repeated for a short period of time before reverting back to a longer period.
syncDeviceSynchronize the device's information with the Cloud.
unregister

Slot Details ​


allBackupTasks ​

BackupTask[] allBackupTasks()


checkSyncDevice ​

Void checkSyncDevice()

Checks whether the device needs to be synchronized or not.


cleanupTunnelledConnections ​

Void cleanupTunnelledConnections()


connect ​

Void connect()


createPermanentBackup ​

BackupTask createPermanentBackup(File file)


createRollingBackup ​

BackupTask createRollingBackup(File file)


createTunnel ​

Void createTunnel(Uri uri, Str:Str headers, Str deviceId, Str host, Str org, Str env)


disconnect ​

Void disconnect()


getBackupTask ​

BackupTask? getBackupTask(Str id)


getCertificateSigningRequest ​

Str getCertificateSigningRequest()

Return the certificate signing request.


getDiagnostics ​

Str:Obj getDiagnostics()


getMessageHandlers ​

MessageHandler[] getMessageHandlers()


hasCertificate ​

Bool hasCertificate()

Return true if the certificate is available.


make ​

new make(MessageQueue mq, CertificateRepository certRepo, ConnectionDataStore connectionDataStore, WebServiceClient webClient, |Duration->Future| scheduleConnectionRetry, |->Future| scheduleCheckSyncDevice, Log log, Sys sys, HttpProxyReqProcessor? requestProcessor := null)


onBackupMessage ​

Void onBackupMessage(Str:Str backupMsg)


register ​

Void register(MessageHandler[] messageHandlers)


resetDeviceRegistration ​

Void resetDeviceRegistration()

Reset the device registration.


resetPreConnectRetryCount ​

Void resetPreConnectRetryCount()

Reset the pre-connect retry count will mean retries will be repeated for a short period of time before reverting back to a longer period.


syncDevice ​

Void syncDevice()

Synchronize the device's information with the Cloud. If we're not connected then do nothing.


unregister ​

Void unregister(MessageHandler[] messageHandlers)


DeletedMessageHandler ​

const class DeletedMessageHandler : Obj, MessageHandler

Handler for when the Cloud has deleted the device's identity in the Cloud.

Constructors

make

Methods

getTopic
onMessage

Slot Details ​


getTopic ​

virtual override Str getTopic(MessageContext cx)


make ​

new make(CloudConnectionService service, Log log)


onMessage ​

virtual override Void onMessage(Str topic, Buf reqBuf, MessageQueue mq, MessageContext cx)


DeviceSyncEncoder ​

class DeviceSyncEncoder : Obj

Encodes device, project and site information objects that can be encoded to JSON.

Constructors

make

Methods

canSyncProjReturn true if we can synchronize the project with the Cloud.
encodeDevice
encodeProject
encodeSite

Slot Details ​


canSyncProj ​

static Bool canSyncProj(Proj proj)

Return true if we can synchronize the project with the Cloud.


encodeDevice ​

Str:Obj encodeDevice()


encodeProject ​

Str:Obj encodeProject(Proj proj)


encodeSite ​

Str:Obj encodeSite(Proj proj, Dict site)


make ​

new make(Str registered, Str[] licenseIds, Sys sys, MessageContext cx)


DeviceSyncVisitor ​

mixin DeviceSyncVisitor

Visitor used for device synchronization.

Methods

visitDeviceCalled when a device is visited.
visitProjectCalled when a project is visited.
visitSiteCalled when a site is visited.

Slot Details ​


visitDevice ​

abstract Void visitDevice()

Called when a device is visited.


visitProject ​

abstract Void visitProject(Proj proj)

Called when a project is visited.


visitSite ​

abstract Void visitSite(Proj proj, Dict site)

Called when a site is visited.


DeviceSynchronizer ​

class DeviceSynchronizer : Obj

Synchronizes the information in FIN with Edge2Cloud.

Constructors

make

Fields

lastDeviceSync
totalDeviceSyncs

Methods

checkSyncChecks whether the device needs to be synchronized or not.
syncAllSynchronize the device's information with the Cloud.
syncSitesSynchronize the device's site information with the Cloud only if a site record has changed.

Slot Details ​


checkSync ​

Void checkSync(MessageContext cx)

Checks whether the device needs to be synchronized or not.


lastDeviceSync ​

DateTime? lastDeviceSync


make ​

new make(MessageQueue mq, CertificateRepository certRepo, Log log, Sys sys)


syncAll ​

Void syncAll(MessageContext cx, Str curVer := ...)

Synchronize the device's information with the Cloud. If we're not connected then do nothing.


syncSites ​

Void syncSites(MessageContext cx)

Synchronize the device's site information with the Cloud only if a site record has changed.


totalDeviceSyncs ​

Int totalDeviceSyncs := 0


FileUploadHandler ​

class FileUploadHandler : Obj

Handles uploading a file.

Constructors

make

Methods

chunkFileToHttpPutUpload the file via several HTTP PUT operations.

Slot Details ​


chunkFileToHttpPut ​

static Str[] chunkFileToHttpPut(File file, |Int->Str| getUrl, |Int| updateProgress)

Upload the file via several HTTP PUT operations.


make ​

new make()


FinEdge2CloudLib ​

const class FinEdge2CloudLib : Obj

Axon functions for Edge2Cloud

Constructors

make

Methods

finEdge2CloudAllBackupTasks
finEdge2CloudApp
finEdge2CloudBackupTask
finEdge2CloudCancelBackupTask
finEdge2CloudCreatePermanentBackup
finEdge2CloudCreatePermanentBackupSync
finEdge2CloudCreateRollingBackup
finEdge2CloudCreateRollingBackupSync
finEdge2CloudDiagnostics
finEdge2CloudDiagnosticsForm
finEdge2CloudIsConnected
finEdge2CloudResetDeviceRegistration
finEdge2CloudSettings
finEdge2CloudSyncDevice
finHttpGetAn Axon function used for fetching grids from an HTTP end point.
finHttpPostAn Axon function used for posting grids to HTTP end points.
finHttpPutAn Axon function used for putting grids to HTTP end points.

Slot Details ​


finEdge2CloudAllBackupTasks ​

@Axon { admin=true; meta=... } Grid finEdge2CloudAllBackupTasks()


finEdge2CloudApp ​

@Axon { su=true; meta=... } Grid finEdge2CloudApp()


finEdge2CloudBackupTask ​

@Axon { admin=true; meta=... } Grid finEdge2CloudBackupTask(Ref backupId)


finEdge2CloudCancelBackupTask ​

@Axon { admin=true; meta=... } Grid finEdge2CloudCancelBackupTask(Ref backupId)


finEdge2CloudCreatePermanentBackup ​

@Axon { admin=true; meta=... } Grid finEdge2CloudCreatePermanentBackup(Obj backupFile)


finEdge2CloudCreatePermanentBackupSync ​

@Axon { admin=true; meta=... } Grid finEdge2CloudCreatePermanentBackupSync(Obj backupFile)


finEdge2CloudCreateRollingBackup ​

@Axon { admin=true; meta=... } Grid finEdge2CloudCreateRollingBackup(Obj backupFile)


finEdge2CloudCreateRollingBackupSync ​

@Axon { admin=true; meta=... } Grid finEdge2CloudCreateRollingBackupSync(Obj backupFile)


finEdge2CloudDiagnostics ​

@Axon { su=true; meta=... } Grid finEdge2CloudDiagnostics()


finEdge2CloudDiagnosticsForm ​

@Axon { su=true; meta=... } Grid finEdge2CloudDiagnosticsForm()


finEdge2CloudIsConnected ​

@Axon { admin=true; meta=... } Bool finEdge2CloudIsConnected()


finEdge2CloudResetDeviceRegistration ​

@Axon { su=true } Void finEdge2CloudResetDeviceRegistration()


finEdge2CloudSettings ​

@Axon { su=true; meta=... } Grid finEdge2CloudSettings()


finEdge2CloudSyncDevice ​

@Axon { admin=true; meta=... } Grid finEdge2CloudSyncDevice()


finHttpGet ​

@Axon { meta=... } Grid finHttpGet(Uri uri, Dict headers := Etc.emptyDict())

An Axon function used for fetching grids from an HTTP end point.

Please note, a similar function called ioReadJson() does exist as part of SkySpark. This function does not handle different content types and HTTP headers.

If a secure authentication token needs to be used to make the request, specify it in the headers. Note this looks up the token indirectly so it's not hard coded into the Axon function...

finHttpGet(`https://test.remote.dev-e2cloud.io/api/demo/read?filter=site`, { authorization: "Bearer $FIN_AUTH_TOKEN_MYTOKEN" })

A dict can be specified as a second argument for extra HTTP headers. By default Zinc encoding is used for the grid but this can be changed to <application/json> if specified in the <content-type> header.

The <$FIN_AUTH_TOKEN_MYTOKEN> token is looked up from the project's password store. The token name must start with <FIN_AUTH_TOKEN_>. Use the passwordSet() Axon function to set the the token's secret...

passwordSet("FIN_AUTH_TOKEN_MYTOKEN", "mySuperSecretPassword")

In this example, a REST API is called and its result written to a record in the database...

() => do
  res: finHttpGet(`https://jsonplaceholder.typicode.com/todos/1`)
    .first
    .set("restApiResult", marker())
    .remove("id")

  rec: read(restApiResult, false)

  if (rec == null)
    diff(null, res, {add}).commit
  else
    diff(rec, res).commit
end

finHttpPost ​

@Axon { admin=true; meta=... } Grid finHttpPost(Grid grid, Uri uri, Dict headers := Etc.emptyDict())

An Axon function used for posting grids to HTTP end points.

For example, post all site data to another server...

readAll("site").finHttpPost(`https://postman-echo.com/post`)

A dict can be specified as a second argument for extra HTTP headers. By default Zinc encoding is used for the grid but this can be changed to <application/json> if specified in the <content-type> header.

If a secure authentication token needs to be used to make the request, specify it in the headers. Note this looks up the token indirectly so it's not hard coded into the Axon function...

readAll("site").finHttpPost(`https://test.remote.dev-e2cloud.io/something`, { authorization: "Bearer $FIN_AUTH_TOKEN_MYTOKEN" })

The <$FIN_AUTH_TOKEN_MYTOKEN> token is looked up from the project's password store. The token name must start with <FIN_AUTH_TOKEN_>. Use the passwordSet() Axon function to set the the token's secret...

passwordSet("FIN_AUTH_TOKEN_MYTOKEN", "mySuperSecretPassword")

finHttpPut ​

@Axon { admin=true; meta=... } Grid finHttpPut(Grid grid, Uri uri, Dict headers := Etc.emptyDict())

An Axon function used for putting grids to HTTP end points.

For example, put all site data to another server...

readAll("site").finHttpPut(`https://postman-echo.com/post`)

A dict can be specified as a second argument for extra HTTP headers. By default Zinc encoding is used for the grid but this can be changed to <application/json> if specified in the <content-type> header.

If a secure authentication token needs to be used to make the request, specify it in the headers. Note this looks up the token indirectly so it's not hard coded into the Axon function...

readAll("site").finHttpPut(`https://test.remote.dev-e2cloud.io/something`, { authorization: "Bearer $FIN_AUTH_TOKEN_MYTOKEN" })

The <$FIN_AUTH_TOKEN_MYTOKEN> token is looked up from the project's password store. The token name must start with <FIN_AUTH_TOKEN_>. Use the passwordSet() Axon function to set the the token's secret...

passwordSet("FIN_AUTH_TOKEN_MYTOKEN", "mySuperSecretPassword")

make ​

new make(FinEdge2CloudMod mod)


FinEdge2CloudMod ​

const class FinEdge2CloudMod : SysMod

FIN Edge2Cloud Sys Mod

A SysMod is used to extend SkySpark as the very core level. This particular type is dynamically injected into the runtime by fin's custom boot environment.

Fields

apiRequired to register the sys mod dynamically in the fin boot environment.
libAs per the OEM developer documentation, this mounts the Axon function the sys mod exposes.
preAuthenticateRequired pre-authentication handler used by sys mod.
webSpecial web service handling.

Methods

onStart
onStop
settingsSettings for FIN Edge2Cloud.

Slot Details ​


api ​

const static Str api := FinEdge2CloudMod#.pod().name

Required to register the sys mod dynamically in the fin boot environment. This is detected via reflection.


lib ​

const FinEdge2CloudLib lib := FinEdge2CloudLib.<ctor>(this)

As per the OEM developer documentation, this mounts the Axon function the sys mod exposes.


onStart ​

virtual override Void onStart()


onStop ​

virtual override Void onStop()


preAuthenticate ​

const static |Sys,WebReq,WebRes->WebServerSession?| preAuthenticate := MemWeb.getPreAuthenticate

Required pre-authentication handler used by sys mod. This is detected via reflection.


settings ​

virtual override FinEdge2CloudSettings settings()

Settings for FIN Edge2Cloud.


web ​

virtual const override FinEdge2CloudWeb web := FinEdge2CloudWeb.<ctor>(this)

Special web service handling.


FinEdge2CloudSettings ​

const class FinEdge2CloudSettings : Settings

Settings for FIN Edge2Cloud.

Currently edited via <var/host/folio.trio>. See id:@finEdge2Cloud.

Constructors

make

Fields

applyUserTagsFuncAxon callback function used to set/change tags on a user before the HttpProxyMessageHandler processes the request.

Slot Details ​


applyUserTagsFunc ​

@Setting { meta="multiLine" } const Str applyUserTagsFunc := ""

Axon callback function used to set/change tags on a user before the HttpProxyMessageHandler processes the request. The function should take one parameter (user) where user is the current User Dict. Returns the updated User Dict.

Example:

(user) => do
  return user.set("finProjectRef", "foo/bar")
end

Please note that this function is called for every request so should be kept efficient. The Context only has access to other functions at the Host level.


make ​

new make(|This| f)


FinEdge2CloudWeb ​

const class FinEdge2CloudWeb : SysWeb

Extensions to the web server.

Handles all paths from </finEdge2Cloud>.

Constructors

make

Fields

mod

Methods

onService

Slot Details ​


make ​

new make(FinEdge2CloudMod mod)


mod ​

const FinEdge2CloudMod mod


onService ​

virtual override Void onService()


Hayson ​

const class Hayson : Obj

Haystack JSON (Hayson) utilities

Methods

encodeValueEncode the haystack value to JSON.

Slot Details ​


encodeValue ​

static Obj? encodeValue(Obj? value)

Encode the haystack value to JSON.


Http ​

const class Http : Obj

HTTP utilities

Methods

requestMake an HTTP request with the chosen method, URI and headers.

Slot Details ​


request ​

static Grid request(Str method, Uri uri, Dict headers, Grid? grid)

Make an HTTP request with the chosen method, URI and headers. Encode the grid if specified.

Return any grid decoded from the response.


HttpProxyMessageHandler ​

const class HttpProxyMessageHandler : ReqResMessageHandler

Message handler for the http proxy traffic.

Constructors

make

Methods

getResponsePayload
getSubTopic

Slot Details ​


getResponsePayload ​

virtual override Buf getResponsePayload(Str blockId, Buf reqPayload, MessageQueue mq, MessageContext cx)


getSubTopic ​

virtual override Str getSubTopic()


make ​

new make(Sys sys, Log log, HttpProxyReqProcessor? requestProcessor := null)


HttpProxyReqProcessor ​

const mixin HttpProxyReqProcessor

An abstraction for processing HTTP proxy requests.

Methods

process

Slot Details ​


process ​

abstract WebRes process(Sys sys, WebReq req, Log log)


MessageContext ​

const class MessageContext : Obj

Holds common contextual information for the processing and sending of messages.

Constructors

make

Fields

NULL_MESSAGE_CONTEXT
deviceId
env
host
org

Slot Details ​


NULL_MESSAGE_CONTEXT ​

const static MessageContext NULL_MESSAGE_CONTEXT := MessageContext.<ctor>("", "", "", "")


deviceId ​

const Str deviceId


env ​

const Str env


host ​

const Str host


make ​

new make(Str deviceId, Str host, Str org, Str env)


org ​

const Str org


MessageHandler ​

const mixin MessageHandler

A message handler uses a message queue to publish, subscribe and unsubscribe to messages.

Methods

getDeviceSubTopicReturns a device topic with the specified sub-topic.
getDeviceTopicReturns a device topic.
getTopicThe topic the message handler is keyed against.
onMessageCalled when a new message is received with the topic, payload buffer and the associated message queue.

Slot Details ​


getDeviceSubTopic ​

static Str getDeviceSubTopic(Str deviceId, Str subTopic, MessageContext cx)

Returns a device topic with the specified sub-topic.


getDeviceTopic ​

static Str getDeviceTopic(Str deviceId, MessageContext cx)

Returns a device topic.


getTopic ​

abstract Str getTopic(MessageContext cx)

The topic the message handler is keyed against.


onMessage ​

abstract Void onMessage(Str topic, Buf reqBuf, MessageQueue mq, MessageContext cx)

Called when a new message is received with the topic, payload buffer and the associated message queue.


MessagePublishVisitor ​

class MessagePublishVisitor : Obj, DeviceSyncVisitor

A device sync visitor that encodes and publishes messages.

Constructors

make

Fields

siteStatuses

Methods

visitDevice
visitProject
visitSite

Slot Details ​


make ​

new make(Str deviceId, MessageQueue mq, MessageContext cx, DeviceSyncEncoder encoder)


siteStatuses ​

Ref:Str siteStatuses := [Ref:Str][:]


visitDevice ​

virtual override Void visitDevice()


visitProject ​

virtual override Void visitProject(Proj proj)


visitSite ​

virtual override Void visitSite(Proj proj, Dict site)


MessageQueue ​

mixin MessageQueue

A message queue implementation that's used to publish, subscribe and unsubscribe to messages.

Methods

connectConnect to a remote message queue broker.
disconnectDisconnect from the message queue broker.
getServerPortThe server connection port.
publishPublish a message for the specified topic and payload.
subscribeSubscribe to a topic.
totalPublishedMessagesTotal number of published messages.
totalSubscribedTotal number of subscription calls.
totalSubscribedMessagesTotal number of subscribed messages.
totalUnsubscribedTotal number of unsubscription calls.
unsubscribeUnsubscribe to a topic.

Slot Details ​


connect ​

abstract Void connect(MessageContext cx)

Connect to a remote message queue broker.


disconnect ​

abstract Void disconnect()

Disconnect from the message queue broker.


getServerPort ​

abstract Int getServerPort()

The server connection port.


publish ​

abstract Void publish(Str topic, Buf payload)

Publish a message for the specified topic and payload.


subscribe ​

abstract Void subscribe(Str topic, |Str,Buf| subscribeCallback)

Subscribe to a topic. The callback will be invoked when a message with the specified is processed by the message queue.


totalPublishedMessages ​

abstract Int totalPublishedMessages()

Total number of published messages.


totalSubscribed ​

abstract Int totalSubscribed()

Total number of subscription calls.


totalSubscribedMessages ​

abstract Int totalSubscribedMessages()

Total number of subscribed messages.


totalUnsubscribed ​

abstract Int totalUnsubscribed()

Total number of unsubscription calls.


unsubscribe ​

abstract Void unsubscribe(Str topic)

Unsubscribe to a topic.


MockCertificateRepository ​

class MockCertificateRepository : Obj, CertificateRepository

A mock certificate repository for unit testing

Fields

CSR
KEY_STORE_PASSWORD
KID
certificate
csr
deviceId
keyStore
kid
notBefore

Methods

getCertificateSigningRequest
getDeviceId
getKeyId
getKeyStore
getKeyStorePassword
getNotBeforeCertificateDate
hasCertificate
hasCsrBeenGenerated
reset
saveCertificate
setDeviceId

Slot Details ​


CSR ​

const static Str CSR := "certificateSigningRequest"


KEY_STORE_PASSWORD ​

const static Str KEY_STORE_PASSWORD := "aPassword"


KID ​

const static Str KID := "keyId"


certificate ​

Str certificate := ""


csr ​

Str csr := ""


deviceId ​

Str deviceId := ""


getCertificateSigningRequest ​

virtual override Str getCertificateSigningRequest(Str hostId)


getDeviceId ​

virtual override Str getDeviceId()


getKeyId ​

virtual override Str getKeyId()


getKeyStore ​

virtual override KeyStore getKeyStore()


getKeyStorePassword ​

virtual override Str getKeyStorePassword()


getNotBeforeCertificateDate ​

virtual override Str getNotBeforeCertificateDate()


hasCertificate ​

virtual override Bool hasCertificate()


hasCsrBeenGenerated ​

virtual override Bool hasCsrBeenGenerated()


keyStore ​

KeyStore keyStore := ...


kid ​

Str kid := "kid"


notBefore ​

Str notBefore := "2019-12-05T11:36:18.020Z"


reset ​

virtual override Void reset()


saveCertificate ​

virtual override Void saveCertificate(Str certificate)


setDeviceId ​

virtual override Void setDeviceId(Str deviceId)


MockConnectionDataStore ​

class MockConnectionDataStore : Obj, ConnectionDataStore

A mock connection data store for unit testing

Fields

connected

Methods

setConnected

Slot Details ​


connected ​

Bool connected := false


setConnected ​

virtual override Void setConnected(Bool connected)


MockHttpProxyReqProcessor ​

const class MockHttpProxyReqProcessor : Obj, HttpProxyReqProcessor

A mock HTTP proxy request processor for testing.

Constructors

make

Fields

processImpl

Methods

process

Slot Details ​


make ​

new make(|Sys,WebReq,Log->WebRes| processImpl)


process ​

virtual override WebRes process(Sys sys, WebReq req, Log log)


processImpl ​

const |Sys,WebReq,Log->WebRes| processImpl


MockMessageHandler ​

const class MockMessageHandler : Obj, MessageHandler

A mock message handler for unit testing

Fields

TOPIC
subscribeCallback

Methods

getTopic
onMessage

Slot Details ​


TOPIC ​

const static Str TOPIC := "fooTopic"


getTopic ​

virtual override Str getTopic(MessageContext cx)


onMessage ​

virtual override Void onMessage(Str topic, Buf reqBuf, MessageQueue mq, MessageContext cx)


subscribeCallback ​

const |Str,Buf,MessageContext| subscribeCallback := |Obj?,Obj?,Obj?->Void| { ... }


MockMessageQueue ​

class MockMessageQueue : Obj, MessageQueue

A mock message queue used for testing

Fields

connected
cx
lastPublishPayload
lastPublishTopic
lastSubscribeCallback
lastSubscribeTopic
lastUnsubscribeTopic
subscribeCount
throwConnectErr
unsubscribeCount

Methods

connect
disconnect
getServerPort
publish
subscribe
totalPublishedMessages
totalSubscribed
totalSubscribedMessages
totalUnsubscribed
unsubscribe

Slot Details ​


connect ​

virtual override Void connect(MessageContext cx)


connected ​

Bool connected := false


cx ​

MessageContext cx := MessageContext.NULL_MESSAGE_CONTEXT


disconnect ​

virtual override Void disconnect()


getServerPort ​

virtual override Int getServerPort()


lastPublishPayload ​

Buf? lastPublishPayload


lastPublishTopic ​

Str lastPublishTopic := ""


lastSubscribeCallback ​

|Str,Buf|? lastSubscribeCallback


lastSubscribeTopic ​

Str lastSubscribeTopic := ""


lastUnsubscribeTopic ​

Str lastUnsubscribeTopic := ""


publish ​

virtual override Void publish(Str topic, Buf payload)


subscribe ​

virtual override Void subscribe(Str topic, |Str,Buf| subscribeCallback)


subscribeCount ​

Int subscribeCount := 0


throwConnectErr ​

Bool throwConnectErr


totalPublishedMessages ​

virtual override Int totalPublishedMessages()


totalSubscribed ​

virtual override Int totalSubscribed()


totalSubscribedMessages ​

virtual override Int totalSubscribedMessages()


totalUnsubscribed ​

virtual override Int totalUnsubscribed()


unsubscribe ​

virtual override Void unsubscribe(Str topic)


unsubscribeCount ​

Int unsubscribeCount := 0


MockTunnel ​

const class MockTunnel : Obj, Tunnel

A mock tunnel.

Fields

_close
_connect
_isAlive
_isConnected
_isExpired
_isInitialized

Methods

close
connect
isAlive
isConnected
isExpired
isInitialized
send

Slot Details ​


_close ​

const AtomicBool _close := AtomicBool.<ctor>(false)


_connect ​

const AtomicBool _connect := AtomicBool.<ctor>(false)


_isAlive ​

const AtomicBool _isAlive := AtomicBool.<ctor>(true)


_isConnected ​

const AtomicBool _isConnected := AtomicBool.<ctor>(false)


_isExpired ​

const AtomicBool _isExpired := AtomicBool.<ctor>(false)


_isInitialized ​

const AtomicBool _isInitialized := AtomicBool.<ctor>(false)


close ​

virtual override Void close()


connect ​

virtual override Void connect()


isAlive ​

virtual override Bool isAlive()


isConnected ​

virtual override Bool isConnected()


isExpired ​

virtual override Bool isExpired()


isInitialized ​

virtual override Bool isInitialized()


send ​

virtual override Void send(Buf payload)


MockTunnelFactory ​

const class MockTunnelFactory : Obj, TunnelFactory

A mock factory for creating tunnels.

Constructors

make

Methods

createReturn a new instance of a tunnel.
getWebSocketTypeReturn the type of web socket being used.

Slot Details ​


create ​

virtual override Tunnel create(Uri uri, Str:Str headers, HttpProxyMessageHandler handler, MessageContext cx, Log log)

Return a new instance of a tunnel.


getWebSocketType ​

virtual override Str getWebSocketType()

Return the type of web socket being used.


make ​

new make(MockTunnel tunnel)


MockWebServiceClient ​

class MockWebServiceClient : Obj, WebServiceClient

A mock web service client for unit testing

Fields

getJsonImpl

Methods

getJson

Slot Details ​


getJson ​

virtual override Str:Obj getJson(Uri uri)


getJsonImpl ​

|Uri->Str:Obj| getJsonImpl := |Obj?->[Str:Obj]| { ... }


PingMessageHandler ​

const class PingMessageHandler : Obj, MessageHandler

A simple ping message handler that responds with the system's current date and time. This is useful for debugging from the AWS IoT Console.

Constructors

make

Methods

getTopic
onMessage

Slot Details ​


getTopic ​

virtual override Str getTopic(MessageContext cx)


make ​

new make(Sys sys, Log log)


onMessage ​

virtual override Void onMessage(Str topic, Buf reqBuf, MessageQueue mq, MessageContext cx)


PropsUtil ​

const class PropsUtil : Obj

Utility methods for accessing configuration properties

Fields

CERTIFICATE_POLL_URL
CLOUD_CLIENT_TIMEOUT
CONFIG_URL
DEBUG
DEVICE_REGISTRATION_URL
ENV
KEEP_ALIVE_INTERVAL
PORTAL_URL
SYNC_DEMO

Methods

get
getConfigProps

Slot Details ​


CERTIFICATE_POLL_URL ​

const static Str CERTIFICATE_POLL_URL := "certificatePollUrl"


CLOUD_CLIENT_TIMEOUT ​

const static Str CLOUD_CLIENT_TIMEOUT := "cloudClientTimeout"


CONFIG_URL ​

const static Str CONFIG_URL := "configUrl"


DEBUG ​

const static Str DEBUG := "debug"


DEVICE_REGISTRATION_URL ​

const static Str DEVICE_REGISTRATION_URL := "deviceRegistrationUrl"


ENV ​

const static Str ENV := "env"


KEEP_ALIVE_INTERVAL ​

const static Str KEEP_ALIVE_INTERVAL := "keepAliveInterval"


PORTAL_URL ​

const static Str PORTAL_URL := "portalUrl"


SYNC_DEMO ​

const static Str SYNC_DEMO := "syncDemo"


get ​

static Str get(Str name)


getConfigProps ​

static Str:Str getConfigProps()


ReqResMessageHandler ​

abstract const class ReqResMessageHandler : Obj, MessageHandler

A message handler for processing request/response style messages from a headend system. Each topic has a req and resp sub topic that' used for handling requests and responses.

Constructors

make

Fields

log
sys

Methods

getBaseTopic
getResponsePayload
getResponseTopic
getSubTopic
getTopic
onMessage

Slot Details ​


getBaseTopic ​

protected Str getBaseTopic(MessageContext cx)


getResponsePayload ​

abstract Buf getResponsePayload(Str id, Buf reqPayload, MessageQueue mq, MessageContext cx)


getResponseTopic ​

protected Str getResponseTopic(MessageContext cx)


getSubTopic ​

abstract Str getSubTopic()


getTopic ​

virtual override Str getTopic(MessageContext cx)


log ​

protected const Log log


make ​

new make(Sys sys, Log log)


onMessage ​

virtual override Void onMessage(Str topic, Buf reqBuf, MessageQueue mq, MessageContext cx)


sys ​

protected const Sys sys


SiteChangedVisitor ​

class SiteChangedVisitor : Obj, DeviceSyncVisitor

A visitor that only publishes site information if the site record has changed.

Constructors

make

Methods

visitDevice
visitProject
visitSite

Slot Details ​


make ​

new make(DeviceSyncVisitor visitor, Ref:Str siteStatuses)


visitDevice ​

virtual override Void visitDevice()


visitProject ​

virtual override Void visitProject(Proj proj)


visitSite ​

virtual override Void visitSite(Proj proj, Dict site)


TestFileUploadHandler ​

class TestFileUploadHandler : Obj

Unit tests that map to Java unit tests.

Constructors

make

Methods

test_output_simple_string
test_output_simple_string_retries_on_error
test_output_simple_string_with_chunk_contents
test_output_simple_string_with_chunk_count
test_output_simple_string_with_progress
test_output_simple_string_with_two_chunks

Slot Details ​


make ​

new make()


test_output_simple_string ​

Void test_output_simple_string()


test_output_simple_string_retries_on_error ​

Void test_output_simple_string_retries_on_error()


test_output_simple_string_with_chunk_contents ​

Void test_output_simple_string_with_chunk_contents()


test_output_simple_string_with_chunk_count ​

Void test_output_simple_string_with_chunk_count()


test_output_simple_string_with_progress ​

Void test_output_simple_string_with_progress()


test_output_simple_string_with_two_chunks ​

Void test_output_simple_string_with_two_chunks()


Tunnel ​

const mixin Tunnel

A tunnelled remote connection.

Methods

closeClose the tunnel.
connectAsynchronously start a tunnel connection.
isAliveReturn true if the tunnel is currently alive.
isConnectedReturn true if the tunnel is connected.
isExpiredReturn true if the tunnel is expired.
isInitializedReturn true if the tunnel is initialized.
sendSend the payload down the websocket.

Slot Details ​


close ​

abstract Void close()

Close the tunnel.


connect ​

abstract Void connect()

Asynchronously start a tunnel connection.


isAlive ​

abstract Bool isAlive()

Return true if the tunnel is currently alive.


isConnected ​

abstract Bool isConnected()

Return true if the tunnel is connected.


isExpired ​

abstract Bool isExpired()

Return true if the tunnel is expired. An expired tunnel hasn't received any messages for a while and can be closed.


isInitialized ​

abstract Bool isInitialized()

Return true if the tunnel is initialized.

An initialized tunnel is one that has attempted to connect.


send ​

abstract Void send(Buf payload)

Send the payload down the websocket.

This must be called from an tunnelled actor.


TunnelDirector ​

class TunnelDirector : Obj

Manages tunnelled connections for remote access.

Constructors

make

Methods

cleanupClean up any unused or closed tunnel connections.
createTunnelAsynchronously create a remote tunnel connection.
disconnectDisconnect all open tunnel connections.
reportDiagnosticsReport the diagnostics for tunnelling.

Slot Details ​


cleanup ​

Void cleanup()

Clean up any unused or closed tunnel connections.


createTunnel ​

Void createTunnel(Uri uri, Str:Str headers, Str deviceId, Str host, Str org, Str env)

Asynchronously create a remote tunnel connection.


disconnect ​

Void disconnect()

Disconnect all open tunnel connections.


make ​

new make(TunnelFactory factory, Log log, Sys sys, HttpProxyReqProcessor? requestProcessor := null)


reportDiagnostics ​

Void reportDiagnostics(Str:Obj diagnostics)

Report the diagnostics for tunnelling.


TunnelFactory ​

const mixin TunnelFactory

A factory that creates an instance of a tunnel.

Methods

createReturn a new instance of a tunnel.
getWebSocketTypeReturn the type of web socket being used.

Slot Details ​


create ​

abstract Tunnel create(Uri uri, Str:Str headers, HttpProxyMessageHandler handler, MessageContext cx, Log log)

Return a new instance of a tunnel.


getWebSocketType ​

abstract Str getWebSocketType()

Return the type of web socket being used.


TunnelFactoryImpl ​

const class TunnelFactoryImpl : Obj, TunnelFactory

A factory implementation that creates an instance of a tunnel.

Methods

createReturn a new instance of a tunnel.
getWebSocketTypeReturn the type of web socket being used.

Slot Details ​


create ​

virtual override Tunnel create(Uri uri, Str:Str headers, HttpProxyMessageHandler handler, MessageContext cx, Log log)

Return a new instance of a tunnel.


getWebSocketType ​

virtual override Str getWebSocketType()

Return the type of web socket being used.


TunnelMessageHandler ​

const class TunnelMessageHandler : Obj, MessageHandler

A message that opens a tunnelled connection for remote access.

Constructors

make

Methods

getTopic
onMessage

Slot Details ​


getTopic ​

virtual override Str getTopic(MessageContext cx)


make ​

new make(CloudConnectionService service, Log log)


onMessage ​

virtual override Void onMessage(Str topic, Buf reqBuf, MessageQueue mq, MessageContext cx)


Util ​

const class Util : Obj

Edge 2 Cloud utility methods.

Fields

ACTOR_POOLAn actor pool so threads can be reused.

Methods

printSlotsPrints out a list of all the slots for a given type.

Slot Details ​


ACTOR_POOL ​

const static ActorPool ACTOR_POOL := ActorPool.<ctor>()

An actor pool so threads can be reused.


printSlots ​

static Void printSlots(Type type)

Prints out a list of all the slots for a given type. This is used for development purposes only.


WebServiceClient ​

mixin WebServiceClient

Used for making client side HTTP requests. Although Fantom has the <WebClient> class there's no way to mock client side requests to outgoing web services hence this interface.

Methods

getJsonMake an HTTP GET and return the parsed JSON in the response.

Slot Details ​


getJson ​

abstract Str:Obj getJson(Uri uri)

Make an HTTP GET and return the parsed JSON in the response. An error will be thrown on the event of an unexpected error.


WsJavaTunnel ​

const class WsJavaTunnel : Obj, Tunnel

A tunnelled remote connection using a Java WebSocket.

Constructors

make

Methods

closeClose the tunnel.
connectAsynchronously start a tunnel connection.
isAliveReturn true if the tunnel is currently alive.
isConnectedReturn true if the tunnel is connected.
isExpiredReturn true if the tunnel is expired.
isInitializedReturn true if the tunnel is initialized.
sendSend the payload down the websocket.

Slot Details ​


close ​

virtual override Void close()

Close the tunnel.


connect ​

virtual override Void connect()

Asynchronously start a tunnel connection.


isAlive ​

virtual override Bool isAlive()

Return true if the tunnel is currently alive.


isConnected ​

virtual override Bool isConnected()

Return true if the tunnel is connected.


isExpired ​

virtual override Bool isExpired()

Return true if the tunnel is expired. An expired tunnel hasn't received any messages for a while and can be closed.


isInitialized ​

virtual override Bool isInitialized()

Return true if the tunnel is initialized.

An initialized tunnel is one that has attempted to connect.


make ​

new make(Uri uri, Str:Str headers, |Buf| callback, Log log)


send ​

virtual override Void send(Buf payload)

Send the payload down the websocket.

This must be called from an tunnelled actor.


WsJavaTunnelWrapper ​

const class WsJavaTunnelWrapper : Obj, Tunnel

Wraps a java web socket tunnel so a message queue can be injected.

Constructors

make

Methods

close
connect
isAlive
isConnected
isExpired
isInitialized
send
toStr

Slot Details ​


close ​

virtual override Void close()


connect ​

virtual override Void connect()


isAlive ​

virtual override Bool isAlive()


isConnected ​

virtual override Bool isConnected()


isExpired ​

virtual override Bool isExpired()


isInitialized ​

virtual override Bool isInitialized()


make ​

new make(Uri uri, Str:Str headers, HttpProxyMessageHandler handler, MessageContext cx, Log log)


send ​

virtual override Void send(Buf payload)


toStr ​

virtual override Str toStr()


WsTunnel ​

const class WsTunnel : Obj, Tunnel

A tunnelled remote connection that uses a Fantom WebSocket.

Constructors

make

Methods

closeSignal the tunnel it must close.
connectAsynchronously start a tunnel connection.
isAliveReturn true if the tunnel is currently alive.
isConnectedReturn true if the tunnel is connected.
isExpiredReturn true if the tunnel is expired.
isInitializedReturn true if the tunnel is initialized.
sendSend the payload down the websocket.
toStrReturn a string representation of the tunnel.

Slot Details ​


close ​

virtual override Void close()

Signal the tunnel it must close.


connect ​

virtual override Void connect()

Asynchronously start a tunnel connection.


isAlive ​

virtual override Bool isAlive()

Return true if the tunnel is currently alive.


isConnected ​

virtual override Bool isConnected()

Return true if the tunnel is connected.


isExpired ​

virtual override Bool isExpired()

Return true if the tunnel is expired. An expired tunnel hasn't received any messages for a while and can be closed.


isInitialized ​

virtual override Bool isInitialized()

Return true if the tunnel is initialized.

An initialized tunnel is one that has attempted to connect.


make ​

new make(Uri uri, Str:Str headers, HttpProxyMessageHandler handler, MessageContext cx, Log log)


send ​

virtual override Void send(Buf payload)

Send the payload down the websocket.

This must be called from an tunnelled actor.


toStr ​

virtual override Str toStr()

Return a string representation of the tunnel.