1 package manager 2 3 import "context" 4 5 // BaseContextFunc is a function used to provide a base Context to Runnables managed by a Manager. 6 type BaseContextFunc func() context.Context 7 8 // Runnable allows a component to be started. 9 // It's very important that Start blocks until it's done running. 10 type Runnable interface { 11 // Start starts running the component. The component will stop running when the context is 12 // closed. Start blocks until the context is closed or an error occurs. 13 Start(context.Context) error 14 } 15 16 // RunnableFunc implements Runnable using a function. 17 // It's very important that the given function block until it's done running. 18 type RunnableFunc func(context.Context) error 19 20 // Start implements Runnable. 21 func (r RunnableFunc) Start(ctx context.Context) error { 22 return r(ctx) 23 } 24