Skip to content

pkg/sdk: implement sdk.Handle() API#11

Merged
hongchaodeng merged 1 commit intooperator-framework:masterfrom
hasbro17:haseeb/register-handler
Feb 14, 2018
Merged

pkg/sdk: implement sdk.Handle() API#11
hongchaodeng merged 1 commit intooperator-framework:masterfrom
hasbro17:haseeb/register-handler

Conversation

@hasbro17
Copy link
Copy Markdown
Contributor

Added the sdk.Handle() API and the related Action type definition.
The informer now invokes the handler.Handle() for an Event to get its Actions.

Comment thread pkg/sdk/informer/informer.go Outdated

type Informer interface {
Run(ctx sdkTypes.Context) error
Run(ctx sdkTypes.Context, handler sdkTypes.Handler) error
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informer should not be coupled to any handler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pkg level handler is registered in pkg/sdk/api.go.
Instead of passing the hanlder to the informer I could add another sdk function to let the informer invoke the handler directly from the sdk package:

func CallHandler(ctx sdkTypes.Context, event sdkTypes.Event) []sdkTypes.Action {
	return handler.Handle(ctx, event)
}

Then the informer sync could just call the registered handler directly:

actions := sdk.CallHandler(i.ctx, event)

@hasbro17 hasbro17 changed the title pkg/sdk: implement sdk.Handle() API [WIP] pkg/sdk: implement sdk.Handle() API Feb 14, 2018
@hasbro17 hasbro17 changed the title [WIP] pkg/sdk: implement sdk.Handle() API pkg/sdk: implement sdk.Handle() API Feb 14, 2018
@hongchaodeng
Copy link
Copy Markdown
Contributor

LGTM

@hongchaodeng hongchaodeng merged commit 181f261 into operator-framework:master Feb 14, 2018
@hongchaodeng hongchaodeng deleted the haseeb/register-handler branch February 14, 2018 22:21
@fanminshi fanminshi mentioned this pull request Feb 14, 2018
21 tasks
fabianvf pushed a commit to fabianvf/operator-sdk that referenced this pull request Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants