jonyfs / eventstore

EventStore interface Example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EventStore Example

In this example, I created a class that implements the EventStore interface.

public interface EventStore {
    void insert(Event event); 

    void removeAll(String type);

    EventIterator query(String type, LocalDateTime startTime, LocalDateTime endTime);
}

Events may be stored in memory, data files, a database, on a remote server, etc. For this example, was implemented an in-memory event event store.

The events in memory was stored in a Syncronized List as below:

public class EventStoreImpl implements EventStore {

    // Creating a thread-safe Event List
    @Getter
    final List<Event> events = Collections.synchronizedList(new ArrayList());
...
}

Collections.synchronizedList() method Returns a synchronized (thread-safe) list backed by the specified list. In order to guarantee serial access, it is critical that all access to the backing list is accomplished through the returned list.

Continuous Integration

Codeship Status for jonyfs/eventstore

Continuous Code Quality

Sonar Cloud

Quality Gate Security Maintainability Coverage Bugs

About

EventStore interface Example


Languages

Language:Java 100.0%