jetbasrawi / go.geteventstore Goto Github PK
View Code? Open in Web Editor NEWA Go Client for EventStore HTTP API
License: BSD 3-Clause "New" or "Revised" License
A Go Client for EventStore HTTP API
License: BSD 3-Clause "New" or "Revised" License
It would be nice to add competing consumers to the go API. I think it would be a simple addition using the HTTP API.
Hi,
for some reason, calling NextVersion does not seem to start reading at the given offset.
Let's say I have 5 events in a stream (EventStore 3.8.x), and I execute
requestReader := commandListener.EventStoreClient.NewStreamReader(requestsStreamName)
requestReader.NextVersion(3)
for requestReader.Next() {
if requestReader.Err() != nil {
panic("error")
} else {
log.WithFields(logrus.Fields{
"currentEvent": requestReader.EventResponse().Event.EventNumber,
}).Info("Current Event")
}
}
I get the output :
Current Event currentEvent=0
Current Event currentEvent=1
Current Event currentEvent=2
Current Event currentEvent=3
In addition, if I pick a NextVersion
higher than the default page size (20
), it is not restarting from 0.
I can see that there is an automated test asserting that this works, but for some reason running the tests complains on my machine about the internal uuid package.
Here is my code, it pulls an event (which is a Click) and the next time it pulls the next event in the stream. However I get the same event back every time.
I can only get it wokring by storing a local version and calling NextVersion(r.version++)
every time.
Here is my Next method which calls the stream readers next function.
func (r *Reader) Next() (*stream.Click, error) {
r.lock.Lock()
defer r.lock.Unlock()
if !r.client.Next() {
return nil, io.EOF
}
if err := r.client.Err(); err != nil {
if _, ok := err.(*goes.ErrNoMoreEvents); ok {
return nil, io.EOF
}
return nil, err
}
o := &stream.Click{}
return o, r.client.Scan(&o, nil)
}
Client.GetEvent
triggers Client.Do
that in a nutshell will hit the API for the given event stream. When this request fails, for instance if EventStore returns 410 for deleted stream, this function Client.Do
will return that error, which is caught in streamreader.go line 123 within the Next()
function. When catching this error, the function will immediately returns true, without incrementing s.version
and s.nextVersion
causing the reader to never move on from this particular event stream.
The concurrent use of multiple StreamReaders means that when using a LongPoll for example, the (normal) reading of a stream is executed after the duration of the LongPoll interval.
This is due to the headers that are declared directly on the client and thus shared across all StreamReaders.
In my opinion, the relevant headers (including "ES-LongPoll") should be carried by the StreamReader and not by the client.
Since the method SetHeader() belongs to the global API of the client, of course, additional headers could be set from outside. To maintain these "external" headers, a workaround when generating the StreamReader would be to create a copy of the client and take all headers except "ES-LongPoll" (or other relevant ES-* headers).
Keeping the HTTP client, the baseURL and the credentials only once in the client makes sense, but not the headers I guess.
Hi I like the simplicity of this library so thank you very much.
I have an issue where I am appending an event but most of the time it does not appear in the EventStore
The EventStore log shows this:
My source code is here if you would be able to take a look
github.com/Brandon2255p/watermill-eventstore/eventstore
Hi,
if someone wants to fork this package it throws an error on compiling/testing in the forked folder
package github.com/forkinguser/go.geteventstore
imports github.com/jetbasrawi/go.geteventstore/internal/uuid: use of internal package not allowed
I can't see the usefulness of including the satori/go.uuid
package in the repository. A better solution would be to import the original package or getting rid of it completely requiring the user to provide a uuid on firing events.
Regards,
Chris
The error occurred:
2017/01/09 04:33:52 http: panic serving [::1]:53823: Concurrency Error.
When I was using map[string]interface{}
as the data, meta type.
err := svc.ES.NewStreamWriter("uppercase").Append(nil, goes.NewEvent(
"", "",
map[string]interface{}{"input": s, "output": u},
map[string]interface{}{},
))
Everything's ok If I changed map[string]interface{}
to map[string]string
.
err := svc.ES.NewStreamWriter("uppercase").Append(nil, goes.NewEvent(
"", "",
map[string]string{"input": s, "output": u},
map[string]string{},
))
Any plans to support the map[string]interface{}
type? Or am I using it in the wrong way?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.