
co.spraybot.messagerunner.DataStoreVerticle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of message-runner Show documentation
Show all versions of message-runner Show documentation
A micro-framework to allow easily passing specific Vert.x messages to specific addresses for processing of those messages.
The newest version!
package co.spraybot.messagerunner;
import io.vertx.core.Future;
import io.vertx.core.Verticle;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
/**
* The ChatBot's DataStoreVerticle, where all of the knowledge it is in possession of is stored.
*
* No explicit connection requests will be sent to the underlying DataStoreVerticle connection, if one is necessary. Connections to
* the underlying persistence system should be triggered when the Verticle starts or stops.
*
* Persistence is often dependent upon network or file I/O this represents a prime opportunity to present blocking code
* and violate the 1st spraybot Directive. Please ensure that your DataStores are asynchronous by design and are not
* allowed to block.
*
* ### Verticle Messages
*
* HardDrives should not publish many messages themselves but act as a server, of sorts, for other Verticles who will send
* RequestResponse style messages with the Request body and headers describing the action to perform and the Response
* being the results of those operations.
*
* - consuming
* - address: spraybot.datastore
* - op: write
* - body: JsonObject With a "key" and "value" element corresponding to the key-value you want to store
* - response: Boolean Whether the data was written successfully or not
*
* - consuming
* - address: spraybot.datastore
* - op: read
* - body: String The key-value you want to retrieve from the store
* - response: T The value that was stored against the key, if there is anything.
*
* - consuming
* - address: spraybot.datastore
* - op: erase
* - body: String The key you want to remove from storage
* - response: Void
*
* - consuming
* - address: spraybot.datastore
* - op: eraseEverything
* - body: null no body required.
* - response: Void
*
* @since 0.1.0
*/
public interface DataStoreVerticle extends Verticle {
/**
* @return The type of Parcel that this ParcelProcessor knows how to work with
*/
default Class getParcelType() {
return DataStoreParcel.class;
}
/**
* @param key The name you want to use to identify this item
* @param value The value of the item
* @return Whether or not the value was successfully put into storage
*/
Future write(String key, JsonObject value);
/**
* @param key The name you want to use to identify this item
* @param value The value of the item
* @return Whether or not the data was successfully put into storage
*/
Future write(String key, JsonArray value);
/**
* @param key The name you want to use to identify this item
* @param value The value of the item
* @return Whether or not the data was successfully put into storage
*/
Future write(String key, String value);
/**
* @param key The name you want to use to identify this item
* @param value The value of the item
* @return Whether or not the data was successfully put into storage
*/
Future write(String key, int value);
/**
* @param key The name you want to use to identify this item
* @param value The value of the item
* @return Whether or not the data was successfully put into storage
*/
Future write(String key, double value);
/**
* @param key The name you want to use to identify this item
* @param value The value of the item
* @return Whether or not the data was successfully put into storage
*/
Future write(String key, boolean value);
/**
* @param key The thing that you want to remember more details about
* @param The type that the value for this key was stored as
* @return The data if we could find one or null.
*/
Future read(String key);
/**
* Remove the HardDriveSector from storage, if one can be found for the given sectorIdentifier.
*
* If there was a value deleted it should be sent as the resolution value of the Future otherwise the future should
* be resolved with nothing.
*
* @param key The identifier for the data you want your ChatBot to erase
* @param The type that the value for this key was stored as
* @return A future that completes successfully when the data has been destroyed
*/
Future erase(String key);
/**
* Destroy every single item that has been stored.
*
* This is a highly destructive action! If you need to have access to data before it is erased in this method it is
* recommended that you erase individual items or read the items you'd like to have access to before erasing
* everything.
*
* @return A future that completes successfully when ALL data has been erased from the DataStoreVerticle
*/
Future eraseEverything();
enum Operation {
WRITE,
READ,
ERASE,
ERASE_EVERYTHING
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy