fsprojects / FSharp.AWS.DynamoDB

F# wrapper API for AWS DynamoDB
MIT License
58 stars 18 forks source link

Add per-Operation collector parameter #41

Closed bartelink closed 2 years ago

bartelink commented 2 years ago
bartelink commented 2 years ago

@samritchie this replaces https://github.com/bartelink/FSharp.AWS.DynamoDB/pull/1

I guess doing explicit try/finally and/or doing the reporting by adding a use __ = { new IDisposable with Dispose() = emitMetrics () } line after the declaration of the consumedMetrics and/or maybeReport to achieve the same effect is overkill ? If not, let me know and I can add it (or feel free to do it yourself - up to you.

Also let me know if you want me to reformat the member definitions to some max line width - I only fixed the most egregious ones here

samritchie commented 2 years ago

@bartelink sorry - I had a go at doing some tests on this and I've had a change of heart, I think a separate TableContext per unique collector is ultimately going to be a better model for most of the common scenarios I can think of. I will have a go at this and maybe get you to cast your eye over it.

bartelink commented 2 years ago

If a TableContext can be cloned / copy constructed neatly enough I guess that might not be the worst idea - it does feel about as neat as having every method in the galaxy take a cancellationToken as it stands ;) Atm in Equinox, I pass in a [Serilog] logger and then decorate it via ForContext to e.g. add retry counts etc to logs - grabbing a tableContext.WithCollectoras part of that same flow would be reasonable.

samritchie commented 2 years ago

Yes, that's what I was thinking - similar to the WithRecordType copy.