Comments (12)
As a counterpoint from a lurker/chicken, in Equinox the default behaviour (when building state) is to not throw or log about this kind of a situation - the thinking being that there are many common cases where you want to ignore some event types:
- blue/green deploys: you typically don't want the old logic to completely explode because you suddenly have a new event in your store
- if you once produced some events in a staging environment and are not worried about the consequence, you must keep your dead event type in the mapping until the end of time
- in any system, over time you inevitably end up with multiple events that are no longer used. There definitely is a period where having this information be in your face in the code is really welcome. But in most long lived systems, there are definitely cases where you don't want to talk about them any more.
- where you have >1 fold/aggregation on a give stream, you don't want to be having to keep two sets of code in sync (not saying you should, but it does happen)
Obviously if you introduce a new financial instrument in your system and it does not consider the new Withdrawal
event to be of consequence, there is absolutely a risk. But it must be balanced with the negatives of having your system be brittle and/or defaulting to mustUnderstand
semantics. Having a mustUnderstandAllEventTypes
that can be set to True
on one's Codec would be useful in that case I guess.
For projections scenarios, I can't imagine anyone wanting logging or exceptions as you're typically white-listing a subset of events
I'd be interested to hear your thoughts as to whether that makes you reconsider or double down...
Would a hook that lets you log or throw in the case of an unknown event type address your desire?
from eventuous.
Eventuous silently stop working when an event type is not registered, which makes it very hard to figure out why things aren't working.
"Stops working" means what exactly? Subscriptions ignore unknown event types by default
I made quite a few improvements for detecting unregistered event types upfront. Eventuous will throw and fail on startup in the following scenarios:
- When using
On<T>
registrations inAggregateState
instead of pattern matching - Same for projections
- Same when using
EventHandler
from eventuous.
I might be wrong though. I think I started it, but it might not be 100% done. But, you get the idea.
When using pattern matching in When
it's almost impossible figure out if all the event types are registered.
from eventuous.
If you can explain what exactly fails and should throw (and doesn't) - I can look closer.
Then again, if the database has events that aren't available in the application - it will always be failing at runtime.
from eventuous.
We happened to log the result of ApplicationService.Handle() which we then could see contained an error message.
The app service results Result
for a reason, so it normally won't be used as a fire-and-forget. Although I see some complications in integration scenarios when you literally don't have any other option than to throw and stop (human intervention required).
It might be mitigated quite simply by checking the result explicitly with if
, by adding an extension to the app service (ThrowOnError
) or by adding an option (requires more obtrusive code change).
from eventuous.
It is my code which stops working. In this particular case I was reading and projecting events, and noticed the projector stopped long before reaching the end. This would probably be a less of a problem if we started out with Eventuous, but we didn't. So we have a mix of old projectors in there.
Investigating further, I noticed that in this case it is the ApplicationService.Handle()
which fails silently. One case was a missing event type, another was an exception thrown by a library which doesn't support record
because of no parameterless ctr.
My problem with this is because of no exception, we got no notification of anything wrong.
I decided to have a look at the source code of ApplicationService
while writing this, and I see now that all exceptions are in fact 'swallowed' and put into an ErrorResult
.
I see problems with this:
- Exceptions are swallowed
- It's not clear from the base type that this is exceptional
- Nothing encourages or forces us to inspect the return value and take proper action
An empty Result
type with a Match(ok => {}, error => {})
would have been nice, which throws when Result is ErrorResult
and Match()
was never called.
from eventuous.
Try this from the latest alpha:
public static IServiceCollection AddApplicationService<T, TAggregate, TState, TId>(
this IServiceCollection services,
bool throwOnError = false
)
from eventuous.
Nothing encourages or forces us to inspect the return value and take proper action
I can't force you to do that, but it's documented https://eventuous.dev/docs/application/app-service/#result
Also, if you add tracing, you will see it right away.
from eventuous.
Try this from the latest alpha:
public static IServiceCollection AddApplicationService<T, TAggregate, TState, TId>( this IServiceCollection services, bool throwOnError = false )
Is it possible without the dependency container?
from eventuous.
Yes, just look at the code of that extension. You need to wrap your app service to a ThrowingApplicationService
.
from eventuous.
@thomaseyde any feedback?
from eventuous.
I will look into it. I see that the case isn't about not throwing, but that I didn't understand how to catch the error. Now that I do, I can do something about it.
from eventuous.
Related Issues (20)
- Avoid unnecessary copy of Payload and Metadata in EsdbEventStore
- Most of the AspNetCore extensions should likely be changed/moved to something more generic HOT 1
- Multitenant implementation HOT 20
- Custom queue name in RMQ gateway subscription
- Crypto Shredding Serialization/Deserialization Support
- Subscriptions sometimes skips events HOT 24
- Postgres subscription is flooding database server with polling queries HOT 3
- Postgres subscription does not automatically reconnect after database server restart HOT 1
- Promote InMemoryEventStore to the main Eventuous library
- Wrong event stream name in EventStoreDB persistent subscription events
- MongoProjector ignores exceptions returning EventHandlingStatus.Success with no logs HOT 1
- Npgsql.PostgresException: 23505: duplicate key value violates unique constraint "pk_checkpoints" HOT 1
- Postgres Store and Sample Booking Application
- Follow RFC 7807: Problem Details for HTTP APIs HOT 4
- Cannot use more than one gateway transformation HOT 1
- [Aggregate Store] Non-intrusive aggregate caching HOT 2
- MapEventuousSpyglass interferes with UseAuthentication and UseAuthorization HOT 1
- Using MapDiscoveredCommands with multiple aggregates results in error 'No handler found for command Object ' HOT 16
- Ability to return a custom return type for a command API reponse HOT 5
- SQL Server __schema__.Streams.StreamName is too big to be indexed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventuous.