io.keen.client.java
Interface KeenEventStore

All Known Implementing Classes:
FileEventStore, RamEventStore

public interface KeenEventStore

Interface which provides an abstraction layer around how events are stored in between being queued and being uploaded by a batch post operation.

Since:
2.0.0

Method Summary
 java.lang.String get(java.lang.Object handle)
          Gets the event corresponding to the given handle.
 java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getHandles(java.lang.String projectId)
          Retrieves a map from collection names to lists of handles currently stored under each collection.
 void remove(java.lang.Object handle)
          Removes the specified event from the store.
 java.lang.Object store(java.lang.String projectId, java.lang.String eventCollection, java.lang.String event)
          Stores the given event.
 

Method Detail

store

java.lang.Object store(java.lang.String projectId,
                       java.lang.String eventCollection,
                       java.lang.String event)
                       throws java.io.IOException
Stores the given event.

Parameters:
projectId - The ID of the project in which the event should be stored.
eventCollection - The name of the collection in which the event should be stored.
event - The serialized JSON for the event to store.
Returns:
A handle which can be used to retrieve or remove the event.
Throws:
java.io.IOException - If there is an error storing the event.

get

java.lang.String get(java.lang.Object handle)
                     throws java.io.IOException
Gets the event corresponding to the given handle.

Parameters:
handle - A handle returned from a previous call to store(String, String, String) or getHandles(String).
Returns:
The serialized JSON for the event, or null if the handle is no longer present in the store.
Throws:
java.io.IOException - If there is an error retrieving the event.

remove

void remove(java.lang.Object handle)
            throws java.io.IOException
Removes the specified event from the store.

Parameters:
handle - A handle returned from a previous call to store(String, String, String) or getHandles(String).
Throws:
java.io.IOException - If there is an error removing the event.

getHandles

java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getHandles(java.lang.String projectId)
                                                                            throws java.io.IOException
Retrieves a map from collection names to lists of handles currently stored under each collection. This will be used by the KeenClient to retrieve the events to send in a batch to the Keen server, as well as to remove all successfully posted events after processing the response.

Parameters:
projectId - The ID of the project for which to retrieve event handles.
Returns:
A map from collection names to lists of handles currently stored under each collection. If there are no events, an empty map will be returned.
Throws:
java.io.IOException - If there is an error retrieving the handles.