Class DefaultEventProcessor
- java.lang.Object
-
- com.launchdarkly.sdk.internal.events.DefaultEventProcessor
-
- All Implemented Interfaces:
EventProcessor
,java.io.Closeable
,java.lang.AutoCloseable
public final class DefaultEventProcessor extends java.lang.Object implements java.io.Closeable, EventProcessor
The internal component that processes and delivers analytics events.This component is not visible to application code; the SDKs may choose to expose an interface for customizing event behavior, but if so, their default implementations of the interface will delegate to this component rather than this component implementing the interface itself. This allows us to make changes as needed to the internal interface and event parameters without disrupting application code, and also to provide internal features that may not be relevant to some SDKs. The current implementation is really three components. DefaultEventProcessor is a simple facade that accepts event parameters (from SDK activity that might be happening on many threads) and pushes the events onto a queue. The queue is consumed by a single-threaded task run by EventDispatcher, which performs any necessary processing such as incrementing summary counters. When events are ready to deliver, it uses an implementation of EventSender (normally DefaultEventSender) to deliver the JSON data.
-
-
Constructor Summary
Constructors Constructor Description DefaultEventProcessor(EventsConfiguration eventsConfig, java.util.concurrent.ScheduledExecutorService sharedExecutor, int threadPriority, com.launchdarkly.logging.LDLogger logger)
Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flushAsync()
Schedules an asynchronous flush.void
flushBlocking()
Flushes and blocks until the flush is done.void
sendEvent(Event e)
Enqueues an event.void
setInBackground(boolean inBackground)
Tells the event processor whether we should be in background mode.void
setOffline(boolean offline)
Tells the event processor whether we should be in background mode.
-
-
-
Constructor Detail
-
DefaultEventProcessor
public DefaultEventProcessor(EventsConfiguration eventsConfig, java.util.concurrent.ScheduledExecutorService sharedExecutor, int threadPriority, com.launchdarkly.logging.LDLogger logger)
Creates an instance.- Parameters:
eventsConfig
- the events configurationsharedExecutor
- used for scheduling repeating tasksthreadPriority
- worker thread prioritylogger
- the logger
-
-
Method Detail
-
sendEvent
public void sendEvent(Event e)
Description copied from interface:EventProcessor
Enqueues an event.- Specified by:
sendEvent
in interfaceEventProcessor
- Parameters:
e
- the input data
-
flushAsync
public void flushAsync()
Description copied from interface:EventProcessor
Schedules an asynchronous flush.- Specified by:
flushAsync
in interfaceEventProcessor
-
flushBlocking
public void flushBlocking()
Description copied from interface:EventProcessor
Flushes and blocks until the flush is done.- Specified by:
flushBlocking
in interfaceEventProcessor
-
setInBackground
public void setInBackground(boolean inBackground)
Description copied from interface:EventProcessor
Tells the event processor whether we should be in background mode. This is only applicable in the client-side (Android) SDK. In background mode, events mostly work the same but we do not send any periodic diagnostic events.- Specified by:
setInBackground
in interfaceEventProcessor
- Parameters:
inBackground
- true if we should be in background mode
-
setOffline
public void setOffline(boolean offline)
Description copied from interface:EventProcessor
Tells the event processor whether we should be in background mode. This is only applicable in the client-side (Android) SDK; in the server-side Java SDK, offline mode does not change dynamically and so we don't even bother to create an event processor if we're offline. In offline mode, events are enqueued but never flushed, and diagnostic events are not sent.- Specified by:
setOffline
in interfaceEventProcessor
- Parameters:
offline
- true if we should be in offline mode
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-