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

added startAsync #102

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ func (m *manager) Start() error {
return nil
}

func (m *manager) StartAsync() (<-chan struct{}, error) {
err := m.start()
if err != nil {
return nil, err
}

return m.context.Context.Done(), nil
}

func (m *manager) startInterceptors() error {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handlerName := r.Header.Get("VCluster-Plugin-Handler-Name")
Expand Down
4 changes: 4 additions & 0 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func Start() error {
return defaultManager.Start()
}

func StartAsync() (<-chan struct{}, error) {
return defaultManager.StartAsync()
}

func UnmarshalConfig(into interface{}) error {
return defaultManager.UnmarshalConfig(into)
}
Expand Down
6 changes: 6 additions & 0 deletions plugin/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ type Manager interface {
// will stop if the pod will lose leader election.
Start() error

// Start runs all the registered syncers and will not block. It only executes
// the functionality if the current vcluster pod is the current leader
// You need to exit the plugin when the channel is closed since that means you lost
// leader election
StartAsync() (<-chan struct{}, error)

// UnmarshalConfig retrieves the plugin config from environment and parses it into
// the given object.
UnmarshalConfig(into interface{}) error
Expand Down
Loading