So this kind of depends on #92
But right now we have these if statements that do validation based on an if type check.
if t, ok := event.(SomeBusV5) {
}
However, if we add v6, v7, v8, this if statement will just keep growing. The handler pattern works really well here.
var defaultHandlers CDEventClientHandlers = NewCDEventClientHandlers()
.Add("v5-validation", SomeBusV5Validator)
// then when users create clients we can just inject the default handlers
func NewCDEventsClient(ctx context.Context, options ...CDEventClientOption) (*CDEventsClient, err) {
client := &CDEventsClient {
ClientHandlers: defaultHandlers,
}
return client
}
So this kind of depends on #92
But right now we have these if statements that do validation based on an if type check.
However, if we add v6, v7, v8, this if statement will just keep growing. The handler pattern works really well here.