Documentation ¶
Index ¶
- func CreateTestFeed(es []*Event, feedURL string) (*atom.Feed, error)
- type AtomFeedSimulator
- type Event
- func CreateTestEvent(stream, server, eventType string, eventNumber int, data *json.RawMessage, ...) *Event
- func CreateTestEventFromData(stream, server string, eventNumber int, data interface{}, meta interface{}) *Event
- func CreateTestEvents(numEvents int, stream string, server string, eventTypes ...string) []*Event
- type EventAtomResponse
- type EventResponse
- type Link
- type TimeStr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTestFeed ¶
CreateTestFeed creates an atom feed object from the events passed in and the url provided.
The function will take the events that correspond to the version number and page size in the url and return a feed object that contains those events. If the url defines a set larger than the events passed in the returned events will only contain the events available.
Types ¶
type AtomFeedSimulator ¶
type AtomFeedSimulator struct { sync.Mutex Events []*Event BaseURL *url.URL MetaData *Event TrickleAfter int // contains filtered or unexported fields }
AtomFeedSimulator is the type that stores configuration and state for the feed simulator.
func NewAtomFeedSimulator ¶
func NewAtomFeedSimulator(events []*Event, baseURL *url.URL, streamMeta *Event, trickleAfter int) (*AtomFeedSimulator, error)
NewAtomFeedSimulator consructs a new AtomFeedSimulator.
events is a slice of *Event that will be returned by the handler. The events are equivalent to the total number of events in a stream and these can be read and paged as you would read and page a stream in GetEventStore. The number of events must be greater than 0.
baseURL is the base url of the test server.
streamMeta is the stream metadata that should be returned if a request for metadata is made to the server.
trickleAfter is used to simulate polling and the arrival of new events while polling. The simulator will return any events after the version specified by the trickleAfter argument. For example, if ten events are passed in and trickleAfter is set to 5, the first five events will be returned in a feed page as if they existed before the request and then a subsequent poll to the head of the stream will return no events. Set the LongPoll header and the simulator will return the next five events at some random interval between 0 seconds and the number of seconds specified by the value of the LongPoll header. If you want all events to be returned as existing, set trickleAfter to -1
func (*AtomFeedSimulator) ServeHTTP ¶
func (h *AtomFeedSimulator) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves atom feed responses
type Event ¶
type Event struct { EventStreamID string `json:"eventStreamId,omitempty"` EventNumber int `json:"eventNumber,omitempty"` EventType string `json:"eventType,omitempty"` EventID string `json:"eventId,omitempty"` Data interface{} `json:"data"` Links []Link `json:"links,omitempty"` MetaData interface{} `json:"metadata,omitempty"` }
Event encapsulates the data of an eventstore event.
EventStreamID is the id returned in the event atom response. EventNumber represents the stream version for this event. EventType describes the event type. EventID is the guid of the event. Data contains the data of the event. Links contains the urls of the event on the evenstore MetaData contains the metadata for the event.
func CreateTestEvent ¶
func CreateTestEvent(stream, server, eventType string, eventNumber int, data *json.RawMessage, meta *json.RawMessage) *Event
CreateTestEvent will generate a test event.
The event data and meta will be a *json.RawMessage. The type of the event returned will be derived from the eventType argument. The event will have a single field named Foo which will contain random content which is simply a uuid string. The meta returned will contain a single field named Bar which will also contain a uuid string.
func CreateTestEventFromData ¶
func CreateTestEventFromData(stream, server string, eventNumber int, data interface{}, meta interface{}) *Event
CreateTestEventFromData returns test events derived from the user specified data
Should be used where you require the simulator to return events of your own type with your own content.
func CreateTestEvents ¶
CreateTestEvents will return a slice of random test events.
The types of the events will be randomly selected from the event type names passed in to the variadic argument eventTypes
func (*Event) PrettyPrint ¶
PrettyPrint renders an indented json view of the Event object.
type EventAtomResponse ¶
type EventAtomResponse struct { Title string `json:"title"` ID string `json:"id"` Updated TimeStr `json:"updated"` Summary string `json:"summary"` Content interface{} `json:"content"` }
EventAtomResponse is used internally to unmarshall the raw response
func CreateTestEventAtomResponse ¶
func CreateTestEventAtomResponse(e *Event, tm *TimeStr) (*EventAtomResponse, error)
CreateTestEventAtomResponse returns an *eventAtomResponse derived from the *Event argument e.
The updated time of the response will be set to the value of the *TimeStr argument tm. If tm is nil then the updated time will be set to now.
func (*EventAtomResponse) PrettyPrint ¶
func (e *EventAtomResponse) PrettyPrint() string
PrettyPrint renders and indented json view of the eventAtomResponse
type EventResponse ¶
EventResponse encapsulates the response for an event reflecting the atom response returned from the server which contains data in addition to the actual event when requested as content type application/vnd.eventstore.atom+json
For more information on the server response see: http://docs.geteventstore.com/http-api/3.7.0/reading-streams/
func CreateTestEventResponse ¶
func CreateTestEventResponse(e *Event, tm *TimeStr) *EventResponse
CreateTestEventResponse will return an *EventResponse containing the event provided in the argument e.
The Updated field of the EventResponse will be set to the value of ht TimeString tm if it is provided otherwise it will be set to time.Now
func CreateTestEventResponses ¶
func CreateTestEventResponses(events []*Event, tm *TimeStr) []*EventResponse
CreateTestEventResponses will return a slice of *EventResponse containing the events provided in the argument events.
The Updated field of the EventResponse will be set to the value of ht TimeString tm if it is provided otherwise it will be set to time.Now
func (*EventResponse) PrettyPrint ¶
func (e *EventResponse) PrettyPrint() string
PrettyPrint renders an indented json view of the EventResponse.