diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-15 15:39:49 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-15 15:46:36 +0100 |
commit | e231b6e83956635e5e4923c064cab19e6730150a (patch) | |
tree | a0740cc0b8b82fac54e9e863e76f7a7ad85cd672 /bridge/core | |
parent | 02548c0e8f96a5c08efe46bd5f71f97fdd211de3 (diff) | |
download | git-bug-e231b6e83956635e5e4923c064cab19e6730150a.tar.gz |
bridges: pass the context to Init for when a client build process needs it
Diffstat (limited to 'bridge/core')
-rw-r--r-- | bridge/core/bridge.go | 20 | ||||
-rw-r--r-- | bridge/core/interfaces.go | 4 |
2 files changed, 8 insertions, 16 deletions
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) } |