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

Dynamic Removal of the Hooks #420

Open
yusufcanb opened this issue Jul 23, 2024 · 1 comment
Open

Dynamic Removal of the Hooks #420

yusufcanb opened this issue Jul 23, 2024 · 1 comment
Labels
discussion Something to be discussed enhancement New feature or request

Comments

@yusufcanb
Copy link

Use Case

@dgduncan, as a user I want to be able to remove, disable or re-enable hooks. This flexibility allows users to configure mochi on runtime which can be very beneficial on various concepts, such as tenant isolation.

Proposal

mqtt.Server has a public method which allows users to add hooks.

server := mqtt.New(nil)
server.AddHook(new(myCustomHook), ...)

For that, a mqtt.HookBase needs to be embedded into custom hook struct.

// ID returns the ID of the hook.
type myCustomHook struct {
	mqtt.HookBase	
}

func (h *myCustomHook ) ID() string {
	return "my-custom-hook"
}

Since every hook has to implement func (...) ID() string than we could find it's reference in the broker hence a server method like below would be straightforward and self-explanatory for the user.

// RemoveHook removes a hook by it's id.
func (s *Server) RemoveHook(id string) error
yusufcanb added a commit to yusufcanb/server that referenced this issue Jul 23, 2024
@thedevop
Copy link
Collaborator

thedevop commented Aug 3, 2024

@yusufcanb, can you elaborate further on the use-case? Providing an example would be helpful.

@thedevop thedevop added enhancement New feature or request discussion Something to be discussed labels Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Something to be discussed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants