Skip to content

Commit

Permalink
added startAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
facchettos committed Jun 28, 2024
1 parent 41f6d72 commit 907b2c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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
5 changes: 5 additions & 0 deletions plugin/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ type Manager interface {
// will stop if the pod will lose leader election.
Start() error

// Start runs all the registered syncers and will block. It only executes
// the functionality if the current vcluster pod is the current leader and
// will stop if the pod will lose 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

0 comments on commit 907b2c0

Please sign in to comment.