final class DatasyncClientImpl extends DatasyncClient
- Alphabetic
- By Inheritance
- DatasyncClientImpl
- DatasyncClient
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new DatasyncClientImpl(app: String, cnxRef: ActorRef, optToken: Option[String])(implicit system: ActorSystem, executor: ExecutionContextExecutor, materializer: ActorMaterializer, sdkConfig: Config)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
authenticate(token: String): Future[Source[AuthMessage, SourceQueueWithComplete[Any]]]
Scala API.
Scala API. Asynchronously performs an authenticate operation on Flexible Datasync, then obtains an akka stream
Source
on which authentication events may be emitted.
Events are formatted as:AuthRevokedMessage(status: String, reason: String)
when authentication is revokedErrorMessage(msg: String)
in case an error occursReconnectedMessage
in case an automatic reconnection occurs
These events extend the
AuthMessage
trait. Example:val manager = DatasyncManager() implicit val executor = manager.executor implicit val materializer = manager.materializer val client = manager.createAppClient("my-datasync-app") val token = "eyJhbGc ... _yz8dN9gssZV9kS8ONgr7s" client.authenticate(token).onComplete { case Success(source) => logger.info("AUTHENTICATION SUCCESS") source.toMat(Sink.foreach(am => logger.debug(s"Event received: $am")))(Keep.left) .run() case Failure(t) => logger.error(s"AUTHENTICATION ERROR: ${t.getMessage}", t) }
This may return some log like the following:
Event received: AuthRevokedMessage(expired_token, Auth token is expired.)
- token
a token used to authenticate on that application.
- returns
a
Future[Source[AuthMessage, SourceQueueWithComplete[Any]]]
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
AuthenticateException
if authentication process failedAuthenticateTimeoutException
if authentication process timed out (automatic re-connection may occur)
-
def
authenticateJ(token: String): CompletionStage[Source[AuthMessage, SourceQueueWithComplete[Any]]]
Java API.
Java API. Asynchronously performs an authenticate operation on Flexible Datasync, then obtains an akka stream
Source
on which authentication events may be emitted.
Events are formatted as:AuthRevokedMessage(status: String, reason: String)
when authentication is revokedErrorMessage(msg: String)
in case an error occursReconnectedMessage
in case an automatic reconnection occurs
These events extend the
AuthMessage
interface. Example:final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); final static String token = "eyJhbGc ... _yz8dN9gssZV9kS8ONgr7s"; client.authenticateJ(token).handleAsync((source, ex) -> { if (source != null) { System.out.printf("AUTHENTICATION SUCCESS \n"); source.runWith( Sink.foreach(am -> System.out.printf("Event received: %s \n", am)), manager.materializer()); } else { System.out.printf("AUTHENTICATION ERROR: %s \n", ex.getMessage()); } return null; });
This may return some log like the following:
Event received: AuthRevokedMessage(expired_token, Auth token is expired.)
- token
a token used to authenticate on that application.
- returns
a
CompletionStage<Source<AuthMessage, SourceQueueWithComplete<Any>>>
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
AuthenticateException
if authentication process failedAuthenticateTimeoutException
if authentication process timed out (automatic re-connection may occur)
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
close(): Unit
Ends this client's Web Socket connection to Datasync, and therefore cancels all pending operations if any.
Ends this client's Web Socket connection to Datasync, and therefore cancels all pending operations if any. Example:
// --------------- // SCALA // --------------- val manager = DatasyncManager() val client = manager.createAppClient("my-datasync-app") // do something with client... client.close // --------------- // JAVA // --------------- final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); // do something with client... client.close();
- Definition Classes
- DatasyncClientImpl → DatasyncClient
-
def
connectionStatus(): Future[Source[CnxStatusMessage, SourceQueueWithComplete[Any]]]
Scala API.
Scala API. Obtains an akka stream
Source
on which connection events may be emitted.
Events are formatted as:ConnectedMessage
as soon as connection is upDisconnectedMessage
in case connection is lostReconnectedMessage
in case connection is up after an automatic reconnectionErrorMessage(msg: String)
in case an error occurs
These events extend the
CnxStatusMessage
trait. Example:val manager = DatasyncManager() implicit val executor = manager.executor implicit val materializer = manager.materializer val client = manager.createAppClient("my-datasync-app") client.connectionStatus().onComplete { case Success(source) => logger.info("CONNECTION STATUS AVAILABLE") source.toMat(Sink.foreach(cm => logger.debug(s"Event received: $cm")))(Keep.left) .run() case Failure(t) => logger.error(s"CONNECTION STATUS ERROR: ${t.getMessage}", t) }
This may return some log like the following:
Event received: ConnectedMessage Event received: DisconnectedMessage Event received: ReconnectedMessage Event received: DisconnectedMessage Event received: ReconnectedMessage
- returns
a
Future[Source[CnxStatusMessage, SourceQueueWithComplete[Any]]]
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
DatasyncConnectionClosedException
if 'close' method has been calledDatasyncUnavailableException
if Web Socket is not available (may be reconnecting)
-
def
connectionStatusJ(): CompletionStage[Source[CnxStatusMessage, SourceQueueWithComplete[Any]]]
Java API.
Java API. Obtains an akka stream
Source
on which connection events may be emitted.
Events are formatted as:ConnectedMessage
as soon as connection is upDisconnectedMessage
in case connection is lostReconnectedMessage
in case connection is up after an automatic reconnectionErrorMessage(msg: String)
in case an error occurs
These events extend the
CnxStatusMessage
interface. Example:final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.connectionStatusJ(token).handleAsync((source, ex) -> { if (source != null) { System.out.printf("CONNECTION STATUS AVAILABLE \n"); source.runWith( Sink.foreach(cm -> System.out.printf("Event received: %s \n", cm)), manager.materializer()); } else { System.out.printf("CONNECTION STATUS ERROR: %s \n", ex.getMessage()); } return null; });
This may return some log like the following:
Event received: ConnectedMessage Event received: DisconnectedMessage Event received: ReconnectedMessage Event received: DisconnectedMessage Event received: ReconnectedMessage
- returns
a
CompletionStage<Source<CnxStatusMessage, SourceQueueWithComplete<Any>>>
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
DatasyncConnectionClosedException
if 'close' method has been calledDatasyncUnavailableException
if Web Socket is not available (may be reconnecting)
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
invalidate_authentication: Future[Unit]
Scala API.
Scala API. Asynchronously invalidate authentication to Flexible Datasync. Example:
val manager = DatasyncManager() implicit val executor = manager.executor val client = manager.createAppClient("my-datasync-app") client.invalidate_authentication.onComplete { case Success(_) => logger.info("INVALIDATE AUTHENTICATION SUCCESS") case Failure(t) => logger.error(s"INVALIDATE AUTHENTICATION ERROR: ${t.getMessage}", t) }
- returns
a
Future[Unit]
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
InvalidateAuthenticationException
if authentication invalidation process failedInvalidateAuthenticationTimeoutException
if authentication invalidation process timed out (automatic re-connection may occur)
-
def
invalidate_authenticationJ: CompletionStage[Unit]
Scala API.
Scala API. Asynchronously invalidate authentication to Flexible Datasync. Example:
final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.invalidate_authenticationJ() .handleAsync((ok, ex) -> { if (ok != null) { System.out.printf("INVALIDATE AUTHENTICATION SUCCESS \n"); } else { System.out.printf("INVALIDATE AUTHENTICATION ERROR: %s \n", ex.getMessage()); } return null; });
- returns
a
CompletionStage<BoxedUnit>
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
InvalidateAuthenticationException
if authentication invalidation process failedInvalidateAuthenticationTimeoutException
if authentication invalidation process timed out (automatic re-connection may occur)
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
listen(path: String, sendCache: Boolean = true): Future[Source[ListenMessage, SourceQueueWithComplete[Any]]]
Scala API.
Scala API. Asynchronously performs a Listen operation on Flexible Datasync, then obtains an akka stream
Source
on which listener's notifications are emitted.
Notifications are formatted as:UpdateMessage(json: String, path: String)
when data is updated on that pathMergeMessage(json: String, path: String)
when data is merged on that pathErrorMessage(msg: String)
in case an error occursReconnectedMessage
in case an automatic reconnection occurs
These notifications extend the
ListenMessage
trait. Example:val manager = DatasyncManager() implicit val executor = manager.executor implicit val materializer = manager.materializer val client = manager.createAppClient("my-datasync-app") client.listen("/my/path", true).onComplete { case Success(source) => logger.info("LISTEN SUCCESS") source.toMat(Sink.foreach(lm => logger.debug(s"Notification received: $lm")))(Keep.left) .run() case Failure(t) => logger.error(s"LISTEN ERROR: ${t.getMessage}", t) }
This may return some log like the following:
Notification received: UpdateMessage({"-Kwf9TIEMb59PB_dyLIm":{"key":"value"},"key2":"value2"},/my/path)
- path
the path where to get notifications, formatted as "some/path/where/to/get notifications".
- sendCache
if true, returned
Source
receives a firstUpdateMessage
notification containing data stored on the path. Defaults to true.- returns
a
Future[Source[ListenMessage, SourceQueueWithComplete[Any]]]
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
ListenException
if LISTEN process failedListenTimeoutException
if LISTEN process timed out (automatic re-connection may occur)
-
def
listenJ(path: String): CompletionStage[Source[ListenMessage, SourceQueueWithComplete[Any]]]
Java API.
Java API. Asynchronously performs a Listen operation on Flexible Datasync, then obtains an akka stream
Source
on which listener's notifications are emitted.
Notifications are formatted as:UpdateMessage(json: String, path: String)
when data is updated on that pathMergeMessage(json: String, path: String)
when data is merged on that pathErrorMessage(msg: String)
in case an error occursReconnectedMessage
in case an automatic reconnection occurs
These notifications extend the
ListenMessage
interface. * A firstUpdateMessage
notification, containing data stored on the path, is sent. Example:final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.listenJ("/my/path").handleAsync((source, ex) -> { if (source != null) { System.out.printf("LISTEN SUCCESS \n"); source.runWith( Sink.foreach(lm -> System.out.printf("Notification received: %s \n", lm)), manager.materializer()); } else { System.out.printf("LISTEN ERROR: %s \n", ex.getMessage()); } return null; });
This may return some log like the following:
Notification received: UpdateMessage({"-Kwf9TIEMb59PB_dyLIm":{"key":"value"},"key2":"value2"},/my/path)
- path
the path where to get notifications, formatted as "some/path/where/to/get notifications".
- returns
a
CompletionStage<Source<ListenMessage, SourceQueueWithComplete<Any>>>
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
ListenException
if LISTEN process failedListenTimeoutException
if LISTEN process timed out (automatic re-connection may occur)
-
def
listenJ(path: String, sendCache: Boolean): CompletionStage[Source[ListenMessage, SourceQueueWithComplete[Any]]]
Java API.
Java API. Asynchronously performs a Listen operation on Flexible Datasync, then obtains an akka stream
Source
on which listener's notifications are emitted.
Notifications are formatted as:UpdateMessage(json: String, path: String)
when data is updated on that pathMergeMessage(json: String, path: String)
when data is merged on that pathErrorMessage(msg: String)
in case an error occursReconnectedMessage
in case an automatic reconnection occurs
These notifications extend the
ListenMessage
interface. Example:final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.listenJ("/my/path", true).handleAsync((source, ex) -> { if (source != null) { System.out.printf("LISTEN SUCCESS \n"); source.runWith( Sink.foreach(lm -> System.out.printf("Notification received: %s \n", lm)), manager.materializer()); } else { System.out.printf("LISTEN ERROR: %s \n", ex.getMessage()); } return null; });
This may return some log like the following:
Notification received: UpdateMessage({"-Kwf9TIEMb59PB_dyLIm":{"key":"value"},"key2":"value2"},/my/path)
- path
the path where to get notifications, formatted as "some/path/where/to/get notifications".
- sendCache
if true, returned
Source
receives a firstUpdateMessage
notification containing data stored on the path.- returns
a
CompletionStage<Source<ListenMessage, SourceQueueWithComplete<Any>>>
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
ListenException
if LISTEN process failedListenTimeoutException
if LISTEN process timed out (automatic re-connection may occur)
- val log: DiagnosticMarkerBusLoggingAdapter
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
once(path: String): Future[String]
Scala API.
Scala API. Asynchronously obtains the content of a Flexible Datasync path. Example:
val manager = DatasyncManager() implicit val executor = manager.executor val client = manager.createAppClient("my-datasync-app") client.once("/my/path").onComplete { case Success(json) => logger.info(s"ONCE SUCCESS: $json") case Failure(t) => logger.error(s"ONCE ERROR: ${t.getMessage}", t) }
This may return some log like the following:
ONCE SUCCESS: {"obj1":{"key1":"value1"},"key2":"value2"}
- path
the path where to retrieve data, formatted as "some/path/where/to/retrieve/data".
- returns
a
Future[String]
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
DatasyncConnectionClosedException
if 'close' method has been calledDatasyncUnavailableException
if Web Socket is not available (may be reconnecting)OnceException
if ONCE process failed
-
def
onceJ(path: String): CompletionStage[String]
Java API.
Java API. Asynchronously obtains the content of a Flexible Datasync path. Example:
final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.onceJ("/my/path").handleAsync((json, ex) -> { if (json != null) { System.out.printf("ONCE SUCCESS: %s \n", json); } else { System.out.printf("ONCE ERROR: %s \n", ex.getMessage()); } return null; });
This may return some log like the following:
ONCE SUCCESS: {"obj1":{"key1":"value1"},"key2":"value2"}
- path
the path where to retrieve data, formatted as "some/path/where/to/retrieve/data".
- returns
a
CompletionStage<String>
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
DatasyncConnectionClosedException
if 'close' method has been calledDatasyncUnavailableException
if Web Socket is not available (may be reconnecting)OnceException
if ONCE process failed
-
def
push(path: String, json: String): Future[String]
Scala API.
Scala API. Asynchronously performs a Push operation on Flexible Datasync. Example:
val manager = DatasyncManager() implicit val executor = manager.executor val client = manager.createAppClient("my-datasync-app") client.push("/my/path", """{"key":"value"}""").onComplete { case Success(id) => logger.info(s"PUSH SUCCESS with additional sub-path $id") case Failure(t) => logger.error(s"PUSH ERROR: ${t.getMessage}", t) }
- path
the path where to push data on that application, formatted as "some/path/to/push/data". If the path does not exist, it will be created in the application's tree. The path is suffixed with a randomly generated level (something like '-KwAf_EG49lohVcG7grO') before data is stored in it. This may be useful to store statistics, for instance.
- json
a JSON string representing the data to push.
- returns
a
Future[String]
containing the unique id added to the path.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
PutOrPushException
if PUSH process failedPutOrPushTimeoutException
if PUSH process timed out (automatic re-connection may occur)
-
def
pushJ(path: String, json: String): CompletionStage[String]
Java API.
Java API. Asynchronously performs a Push operation on Flexible Datasync. Example:
final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.pushJ("/my/path", "{\"key\":\"value\"}") .handleAsync((id, ex) -> { if (id != null) { System.out.printf("PUSH SUCCESS with additional sub-path %s \n", id); } else { System.out.printf("PUSH ERROR: %s \n", ex.getMessage()); } return null; });
- path
the path where to push data on that application, formatted as "some/path/to/push/data". If the path does not exist, it will be created in the application's tree. The path is suffixed with a randomly generated level (something like '-KwAf_EG49lohVcG7grO') before data is stored in it. This may be useful to store statistics, for instance.
- json
a JSON string representing the data to push.
- returns
a
CompletionStage<String>
containing the unique id added to the path.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
PutOrPushException
if PUSH process failedPutOrPushTimeoutException
if PUSH process timed out (automatic re-connection may occur)
-
def
put(path: String, json: String): Future[Unit]
Scala API.
Scala API. Asynchronously performs a Put operation on Flexible Datasync. Example:
val manager = DatasyncManager() implicit val executor = manager.executor val client = manager.createAppClient("my-datasync-app") client.put("/my/path", """{"key":"value"}""").onComplete { case Success(_) => logger.info("PUT SUCCESS") case Failure(t) => logger.error(s"PUT ERROR: ${t.getMessage}", t) }
- path
the path where to put data on that application, formatted as "some/path/to/put/data". If the path does not exist, it will be created in the application's tree.
- json
a JSON string representing the data to put. Notice that existing data, if any, is overwritten by the data to put.
- returns
a
Future[Unit]
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
PutOrPushException
if PUT process failedPutOrPushTimeoutException
if PUT process timed out (automatic re-connection may occur)
-
def
putJ(path: String, json: String): CompletionStage[Unit]
Java API.
Java API. Asynchronously performs a Put operation on Flexible Datasync. Notice that existing data, if any, is overwritten by the data to put. Example:
final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.putJ("/my/path", "{\"key\":\"value\"}") .handleAsync((ok, ex) -> { if (ok != null) { System.out.printf("PUT SUCCESS \n"); } else { System.out.printf("PUT ERROR: %s \n", ex.getMessage()); } return null; });
- path
the path where to put data on that application, formatted as "some/path/to/put/data". If the path does not exist, it will be created in the application's tree.
- json
a JSON string representing the data to put.
- returns
a
CompletionStage<BoxedUnit>
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
PutOrPushException
if PUT process failedPutOrPushTimeoutException
if PUT process timed out (automatic re-connection may occur)
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unlisten(path: String): Future[Unit]
Scala API.
Scala API. Asynchronously ends a Listen operation on Flexible Datasync. Example:
val manager = DatasyncManager() implicit val executor = manager.executor val client = manager.createAppClient("my-datasync-app") client.listen("/my/path", true).onComplete { case Success(_) => logger.info("LISTEN SUCCESS") client.unlisten("/my/path").onComplete { case Success(_) => logger.info("UNLISTEN SUCCESS") case Failure(t) => logger.error(s"UNLISTEN ERROR: ${t.getMessage}", t) } case Failure(t) => logger.error(s"LISTEN ERROR: ${t.getMessage}", t) }
- path
the path where to stop listening to, formatted as "some/path/where/to/stop/listening".
- returns
a
Future[Unit]
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
UnlistenException
if UNLISTEN process failedUnlistenTimeoutException
if UNLISTEN process timed out (automatic re-connection may occur)
-
def
unlistenJ(path: String): CompletionStage[Unit]
Java API.
Java API. Asynchronously ends a Listen operation on Flexible Datasync. Example:
final static DatasyncManager manager = DatasyncManager.create(); final static DatasyncClient client = manager.createAppClient("my-datasync-app"); client.listenJ("/my/path", true) .handleAsync((source, ex) -> { if (source != null) { System.out.printf("LISTEN SUCCESS \n"); client.unlistenJ("/my/path") .handleAsync((ok, ex2) -> { if (ok != null) { System.out.printf("UNLISTEN SUCCESS \n"); } else { System.out.printf("UNLISTEN ERROR: %s \n", ex2.getMessage()); } return null; }); } else { System.out.printf("LISTEN ERROR: %s \n", ex.getMessage()); } return null; });
- path
the path where to stop listening to, formatted as "some/path/where/to/stop/listening".
- returns
a
CompletionStage<BoxedUnit>
that may fail if operation fails.
- Definition Classes
- DatasyncClientImpl → DatasyncClient
- Exceptions thrown
UnlistenException
if UNLISTEN process failedUnlistenTimeoutException
if UNLISTEN process timed out (automatic re-connection may occur)
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )