public abstract class PubSubMessageSerDe extends Object implements Serializable
PubSubMessage
serialization and deserialization - for instance, if you want
to customize what is done to the message before it is sent to or read in the backend. You can implement a custom
version of this to change what the PubSubMessage
contains (see toMessage(PubSubMessage)
) and invert
it when it is read back (see fromMessage(PubSubMessage)
).
Please note that this is not intended to be applied to messages read from the backend or for signals sent to the
backend. You can, for example, use this if you want to customize what is stored in storage or to lazily create a
Query
in the backend.Modifier and Type | Field and Description |
---|---|
protected BulletConfig |
config |
Constructor and Description |
---|
PubSubMessageSerDe(BulletConfig config)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static PubSubMessageSerDe |
from(BulletConfig config)
Create a
PubSubMessageSerDe instance using the class specified in the config file. |
abstract PubSubMessage |
fromMessage(PubSubMessage message)
Takes a converted
PubSubMessage and returns the original format of the message. |
abstract PubSubMessage |
toMessage(PubSubMessage message)
Takes a
PubSubMessage and returns the new format of the message. |
PubSubMessage |
toMessage(String id,
Query query,
String queryString)
A helper to submit a query by converting it to a standard
PubSubMessage and running it through
toMessage(PubSubMessage) . |
protected BulletConfig config
public PubSubMessageSerDe(BulletConfig config)
config
- The BulletConfig
to configure this class.public PubSubMessage toMessage(String id, Query query, String queryString)
PubSubMessage
and running it through
toMessage(PubSubMessage)
.id
- The ID for the query.query
- The Query
object to create a PubSubMessage
.queryString
- The BQL for the query.PubSubMessage
.public abstract PubSubMessage toMessage(PubSubMessage message)
PubSubMessage
and returns the new format of the message. Note that it is allowed to modify the
original message. See fromMessage(PubSubMessage)
for the inverse.message
- The PubSubMessage
to convert.PubSubMessage
.public abstract PubSubMessage fromMessage(PubSubMessage message)
PubSubMessage
and returns the original format of the message. Note that it is allowed
to modify the original message. See toMessage(PubSubMessage)
for the inverse.message
- The PubSubMessage
to revert.PubSubMessage
.public static PubSubMessageSerDe from(BulletConfig config)
PubSubMessageSerDe
instance using the class specified in the config file.config
- The non-null BulletConfig
containing the class name and its settings.Copyright © 2021. All rights reserved.