I was trying to set a maxAge for some streams and it seems like using Go's time.Duration format does not match the format expected by EventStoreDB.
Steps to reproduce:
// ... init esdb.Client
streamID := "some-stream"
// Write event to stream
_, err = db.AppendToStream(context.Background(), streamID, esdb.AppendToStreamOptions{}, eventData)
// Set maxAge of stream to 1 Second
metaData := esdb.StreamMetadata{}
metaData.SetMaxAge(time.Second)
db.SetStreamMetadata(context.Background(), streamID, esdb.AppendToStreamOptions{}, metaData)
// Wait for 2 seconds
time.Sleep(time.Second*2)
// Event still exists here, can be verified using ReadStream or the admin tool (admin tool needs some stream call to refresh)
Unfortunately I don't have the time to take a closer look, so I might have missed something. Nonetheless, I wanted to leave this here for now. Taking a look at SetStreamMetadata, it seems like time.Duration values are directly marshalled to JSON, so the value is written in nanoseconds. EventstoreDB might expect another time unit, but I didn't find anything about that in the documentation. If this is not a mistake from my side, it might be worth checking all time.Duration values used in the client.
I was trying to set a
maxAge
for some streams and it seems like using Go'stime.Duration
format does not match the format expected by EventStoreDB. Steps to reproduce:Unfortunately I don't have the time to take a closer look, so I might have missed something. Nonetheless, I wanted to leave this here for now. Taking a look at
SetStreamMetadata
, it seems liketime.Duration
values are directly marshalled to JSON, so the value is written in nanoseconds. EventstoreDB might expect another time unit, but I didn't find anything about that in the documentation. If this is not a mistake from my side, it might be worth checking all time.Duration values used in the client.