From e231b6e83956635e5e4923c064cab19e6730150a Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 15 Feb 2020 15:39:49 +0100 Subject: bridges: pass the context to Init for when a client build process needs it --- bridge/core/bridge.go | 20 ++++++-------------- bridge/core/interfaces.go | 4 ++-- 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'bridge/core') diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go index c72ff6b4..10f6b109 100644 --- a/bridge/core/bridge.go +++ b/bridge/core/bridge.go @@ -299,14 +299,14 @@ func (b *Bridge) getExporter() Exporter { return b.exporter } -func (b *Bridge) ensureImportInit() error { +func (b *Bridge) ensureImportInit(ctx context.Context) error { if b.initImportDone { return nil } importer := b.getImporter() if importer != nil { - err := importer.Init(b.repo, b.conf) + err := importer.Init(ctx, b.repo, b.conf) if err != nil { return err } @@ -316,22 +316,14 @@ func (b *Bridge) ensureImportInit() error { return nil } -func (b *Bridge) ensureExportInit() error { +func (b *Bridge) ensureExportInit(ctx context.Context) error { if b.initExportDone { return nil } - importer := b.getImporter() - if importer != nil { - err := importer.Init(b.repo, b.conf) - if err != nil { - return err - } - } - exporter := b.getExporter() if exporter != nil { - err := exporter.Init(b.repo, b.conf) + err := exporter.Init(ctx, b.repo, b.conf) if err != nil { return err } @@ -355,7 +347,7 @@ func (b *Bridge) ImportAllSince(ctx context.Context, since time.Time) (<-chan Im return nil, err } - err = b.ensureImportInit() + err = b.ensureImportInit(ctx) if err != nil { return nil, err } @@ -409,7 +401,7 @@ func (b *Bridge) ExportAll(ctx context.Context, since time.Time) (<-chan ExportR return nil, err } - err = b.ensureExportInit() + err = b.ensureExportInit(ctx) if err != nil { return nil, err } diff --git a/bridge/core/interfaces.go b/bridge/core/interfaces.go index 63340a95..f20f1642 100644 --- a/bridge/core/interfaces.go +++ b/bridge/core/interfaces.go @@ -36,11 +36,11 @@ type BridgeImpl interface { } type Importer interface { - Init(repo *cache.RepoCache, conf Configuration) error + Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ImportResult, error) } type Exporter interface { - Init(repo *cache.RepoCache, conf Configuration) error + Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error ExportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ExportResult, error) } -- cgit