Skip to content
Snippets Groups Projects
dubbo_exporter.go 781 B
Newer Older
package dubbo

fangyincheng's avatar
fangyincheng committed
import (
	"context"
)

fangyincheng's avatar
fangyincheng committed
import (
	log "github.com/AlexStocks/log4go"
)

fangyincheng's avatar
fangyincheng committed
import (
	"github.com/dubbo/dubbo-go/protocol"
)

// wrapping invoker
type DubboExporter struct {
fangyincheng's avatar
fangyincheng committed
	ctx         context.Context
	key         string
	invoker     protocol.Invoker
	exporterMap map[string]protocol.Exporter
fangyincheng's avatar
fangyincheng committed
func NewDubboExporter(ctx context.Context, key string, invoker protocol.Invoker, exporterMap map[string]protocol.Exporter) *DubboExporter {
fangyincheng's avatar
fangyincheng committed
	return &DubboExporter{
fangyincheng's avatar
fangyincheng committed
		ctx:         ctx,
		key:         key,
		invoker:     invoker,
		exporterMap: exporterMap,
fangyincheng's avatar
fangyincheng committed
	}
}

func (de *DubboExporter) GetInvoker() protocol.Invoker {
	return de.invoker

}

func (de *DubboExporter) Unexport() {
fangyincheng's avatar
fangyincheng committed
	log.Info("DubboExporter unexport.")
fangyincheng's avatar
fangyincheng committed
	de.invoker.Destroy()
fangyincheng's avatar
fangyincheng committed
	delete(de.exporterMap, de.key)