Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: support Close() for Tracer plugins as well #6672

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion plugin/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ type PluginDaemon interface {
Plugin

Start(coreiface.CoreAPI) error
Close() error
}
5 changes: 3 additions & 2 deletions plugin/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package loader

import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -266,8 +267,8 @@ func (loader *PluginLoader) Close() error {
started := loader.started
loader.started = nil
for _, pl := range started {
if pl, ok := pl.(plugin.PluginDaemon); ok {
err := pl.Close()
if closer, ok := pl.(io.Closer); ok {
err := closer.Close()
if err != nil {
errs = append(errs, fmt.Sprintf(
"error closing plugin %s: %s",
Expand Down
5 changes: 4 additions & 1 deletion plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ type Environment struct {
Config interface{}
}

// Plugin is base interface for all kinds of go-ipfs plugins
// Plugin is the base interface for all kinds of go-ipfs plugins
// It will be included in interfaces of different Plugins
//
// Optionally, Plugins can implement io.Closer if they want to
// have a termination step when unloading.
type Plugin interface {
// Name should return unique name of the plugin
Name() string
Expand Down
1 change: 1 addition & 0 deletions plugin/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import (
// PluginTracer is an interface that can be implemented to add a tracer
type PluginTracer interface {
Plugin

InitTracer() (opentracing.Tracer, error)
}