context passing
This commit is contained in:
+5
-5
@@ -12,17 +12,17 @@ import (
|
||||
"fyne.io/fyne/v2"
|
||||
)
|
||||
|
||||
type ClientInit func(connector.UIConnector, fyne.App, mc.Settings) (mc.Client, error)
|
||||
type ClientInit func(context.Context, connector.UIConnector, fyne.App, mc.Settings) (mc.Client, error)
|
||||
|
||||
type loader struct {
|
||||
conn connector.Connector
|
||||
cli mc.Client
|
||||
}
|
||||
|
||||
func NewLoader(app fyne.App, conn connector.Connector) (*loader, error) {
|
||||
func NewLoader(ctx context.Context, app fyne.App, conn connector.Connector) (*loader, error) {
|
||||
app.Storage().List()
|
||||
settings := mc.Settings{}
|
||||
cli, err := loadClientPlugin(conn, app, settings, "./client.so", "NewClient")
|
||||
cli, err := loadClientPlugin(ctx, conn, app, settings, "./client.so", "NewClient")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func (l *loader) backgroundLoop(ctx context.Context, final <-chan struct{}) {
|
||||
|
||||
// loadClientPlugin loads a Client implementation from a shared object (.so) file at the specified path.
|
||||
// It calls the constructor function by name, passing the necessary dependencies, and returns the initialized Client.
|
||||
func loadClientPlugin(conn connector.UIConnector, app fyne.App, s mc.Settings, path, name string) (mc.Client, error) {
|
||||
func loadClientPlugin(ctx context.Context, conn connector.UIConnector, app fyne.App, s mc.Settings, path, name string) (mc.Client, error) {
|
||||
if path == "" {
|
||||
return nil, errors.New("no plugin path given")
|
||||
}
|
||||
@@ -81,5 +81,5 @@ func loadClientPlugin(conn connector.UIConnector, app fyne.App, s mc.Settings, p
|
||||
return nil, fmt.Errorf("unexpected type %T; want %T", sym, initializerPtr)
|
||||
}
|
||||
|
||||
return (*initializerPtr)(conn, app, s)
|
||||
return (*initializerPtr)(ctx, conn, app, s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user