Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for validation hooks #93

Open
xibz opened this issue Jul 31, 2024 · 0 comments
Open

Allow for validation hooks #93

xibz opened this issue Jul 31, 2024 · 0 comments

Comments

@xibz
Copy link

xibz commented Jul 31, 2024

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

No branches or pull requests

1 participant