mirror of
https://github.com/openziti/ziti.git
synced 2026-10-22 19:56:07 +00:00
Merge pull request openziti/fabric#311 from openziti/update-channel
Update to use channel library
This commit is contained in:
@@ -20,13 +20,12 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/fabric/router/xgress"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/config"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/metrics"
|
||||
@@ -60,7 +59,7 @@ type Config struct {
|
||||
}
|
||||
Mgmt struct {
|
||||
Listener transport.Address
|
||||
Options *channel2.Options
|
||||
Options *channel.Options
|
||||
}
|
||||
Metrics *metrics.Config
|
||||
HealthChecks struct {
|
||||
@@ -238,10 +237,6 @@ func LoadConfig(path string) (*Config, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if controllerConfig.Trace.Handler != nil {
|
||||
controllerConfig.Ctrl.Options.PeekHandlers = append(controllerConfig.Ctrl.Options.PeekHandlers, controllerConfig.Trace.Handler)
|
||||
}
|
||||
} else {
|
||||
panic("controllerConfig [ctrl] section in unexpected format")
|
||||
}
|
||||
@@ -261,10 +256,14 @@ func LoadConfig(path string) (*Config, error) {
|
||||
panic("controllerConfig must provide [mgmt/listener]")
|
||||
}
|
||||
|
||||
controllerConfig.Mgmt.Options = channel2.DefaultOptions()
|
||||
controllerConfig.Mgmt.Options = channel.DefaultOptions()
|
||||
if value, found := submap["options"]; found {
|
||||
if submap, ok := value.(map[interface{}]interface{}); ok {
|
||||
controllerConfig.Mgmt.Options = channel2.LoadOptions(submap)
|
||||
options, err := channel.LoadOptions(submap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
controllerConfig.Mgmt.Options = options
|
||||
if err := controllerConfig.Mgmt.Options.Validate(); err != nil {
|
||||
return nil, fmt.Errorf("error loading channel options for [mgmt/options] (%v)", err)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/api_impl"
|
||||
"github.com/openziti/fabric/controller/handler_ctrl"
|
||||
"github.com/openziti/fabric/controller/handler_mgmt"
|
||||
@@ -34,8 +35,6 @@ import (
|
||||
"github.com/openziti/fabric/health"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/fabric/xweb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/common"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/profiler"
|
||||
@@ -55,7 +54,7 @@ type Controller struct {
|
||||
xwebFactoryRegistry xweb.WebHandlerFactoryRegistry
|
||||
|
||||
ctrlListener channel.UnderlayListener
|
||||
mgmtListener channel2.UnderlayListener
|
||||
mgmtListener channel.UnderlayListener
|
||||
|
||||
shutdownC chan struct{}
|
||||
isShutdown concurrenz.AtomicBoolean
|
||||
@@ -126,7 +125,7 @@ func (c *Controller) Run() error {
|
||||
pfxlog.Logger().Panicf("could not prepare version headers: %v", err)
|
||||
}
|
||||
headers := map[int32][]byte{
|
||||
channel2.HelloVersionHeader: versionHeader,
|
||||
channel.HelloVersionHeader: versionHeader,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,14 +136,15 @@ func (c *Controller) Run() error {
|
||||
if err := c.ctrlListener.Listen(c.ctrlConnectHandler); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ctrlAccepter := handler_ctrl.NewCtrlAccepter(c.network, c.xctrls, c.ctrlListener, c.config.Ctrl.Options.Options)
|
||||
|
||||
ctrlAccepter := handler_ctrl.NewCtrlAccepter(c.network, c.xctrls, c.ctrlListener, c.config.Ctrl.Options.Options, c.config.Trace.Handler)
|
||||
go ctrlAccepter.Run()
|
||||
/* */
|
||||
|
||||
/**
|
||||
* mgmt listener/accepter.
|
||||
*/
|
||||
mgmtListener := channel2.NewClassicListener(c.config.Id, c.config.Mgmt.Listener, c.config.Mgmt.Options.ConnectOptions, headers)
|
||||
mgmtListener := channel.NewClassicListener(c.config.Id, c.config.Mgmt.Listener, c.config.Mgmt.Options.ConnectOptions, headers)
|
||||
c.mgmtListener = mgmtListener
|
||||
if err := c.mgmtListener.Listen(c.mgmtConnectHandler); err != nil {
|
||||
panic(err)
|
||||
@@ -253,7 +253,7 @@ func (c *Controller) registerComponents() error {
|
||||
c.ctrlConnectHandler = handler_ctrl.NewConnectHandler(c.config.Id, c.network, c.xctrls)
|
||||
c.mgmtConnectHandler = handler_mgmt.NewConnectHandler(c.config.Id, c.network)
|
||||
|
||||
c.config.Mgmt.Options.BindHandlers = []channel2.BindHandler{handler_mgmt.NewBindHandler(c.network, c.xmgmts)}
|
||||
c.config.Mgmt.Options.BindHandler = handler_mgmt.NewBindHandler(c.network, c.xmgmts)
|
||||
|
||||
//add default REST XWeb
|
||||
if err := c.RegisterXweb(xweb.NewXwebImpl(c.xwebFactoryRegistry, c.config.Id)); err != nil {
|
||||
|
||||
@@ -2,30 +2,9 @@ package handler_common
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
func SendChannel2Success(request *channel2.Message, ch channel2.Channel, message string) {
|
||||
SendChannel2Result(request, ch, message, true)
|
||||
}
|
||||
|
||||
func SendChannel2Failure(request *channel2.Message, ch channel2.Channel, message string) {
|
||||
SendChannel2Result(request, ch, message, false)
|
||||
}
|
||||
|
||||
func SendChannel2Result(request *channel2.Message, ch channel2.Channel, message string, success bool) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
if !success {
|
||||
log.Errorf("%v error (%s)", ch.LogicalName(), message)
|
||||
}
|
||||
|
||||
response := channel2.NewResult(success, message)
|
||||
response.ReplyTo(request)
|
||||
_ = ch.Send(response)
|
||||
log.Debug("success")
|
||||
}
|
||||
|
||||
func SendSuccess(request *channel.Message, ch channel.Channel, message string) {
|
||||
SendResult(request, ch, message, true)
|
||||
}
|
||||
|
||||
@@ -18,81 +18,93 @@ package handler_ctrl
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xctrl"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type CtrlAccepter struct {
|
||||
network *network.Network
|
||||
xctrls []xctrl.Xctrl
|
||||
listener channel.UnderlayListener
|
||||
options *channel.Options
|
||||
network *network.Network
|
||||
xctrls []xctrl.Xctrl
|
||||
listener channel.UnderlayListener
|
||||
options *channel.Options
|
||||
traceHandler *channel.TraceHandler
|
||||
}
|
||||
|
||||
func NewCtrlAccepter(network *network.Network,
|
||||
xctrls []xctrl.Xctrl,
|
||||
listener channel.UnderlayListener,
|
||||
options *channel.Options) *CtrlAccepter {
|
||||
options *channel.Options,
|
||||
traceHandler *channel.TraceHandler) *CtrlAccepter {
|
||||
return &CtrlAccepter{
|
||||
network: network,
|
||||
xctrls: xctrls,
|
||||
listener: listener,
|
||||
options: options,
|
||||
network: network,
|
||||
xctrls: xctrls,
|
||||
listener: listener,
|
||||
options: options,
|
||||
traceHandler: traceHandler,
|
||||
}
|
||||
}
|
||||
|
||||
func (ctrlAccepter *CtrlAccepter) Run() {
|
||||
func (self *CtrlAccepter) Run() {
|
||||
log := pfxlog.Logger()
|
||||
log.Info("started")
|
||||
defer log.Warn("exited")
|
||||
|
||||
self.options.SetBindHandlerF(self.Bind)
|
||||
|
||||
for {
|
||||
ch, err := channel.NewChannel("ctrl", ctrlAccepter.listener, ctrlAccepter.options)
|
||||
if err == nil {
|
||||
if r, err := ctrlAccepter.network.GetRouter(ch.Id().Token); err == nil {
|
||||
if ch.Underlay().Headers() != nil {
|
||||
if versionValue, found := ch.Underlay().Headers()[channel.HelloVersionHeader]; found {
|
||||
if versionInfo, err := ctrlAccepter.network.VersionProvider.EncoderDecoder().Decode(versionValue); err == nil {
|
||||
r.VersionInfo = versionInfo
|
||||
} else {
|
||||
log.WithError(err).Warn("could not parse version info from router hello, closing router connection")
|
||||
_ = ch.Close()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.Warn("no version info header, closing router connection")
|
||||
_ = ch.Close()
|
||||
return
|
||||
}
|
||||
|
||||
if listenerValue, found := ch.Underlay().Headers()[channel.HelloRouterAdvertisementsHeader]; found {
|
||||
listenerString := string(listenerValue)
|
||||
r.AdvertisedListener = listenerString
|
||||
} else {
|
||||
log.Warn("no advertised listeners")
|
||||
}
|
||||
} else {
|
||||
log.Warn("no attributes provided")
|
||||
}
|
||||
|
||||
r.Control = ch
|
||||
if err := r.Control.Bind(newBindHandler(r, ctrlAccepter.network, ctrlAccepter.xctrls)); err != nil {
|
||||
log.Errorf("error binding router (%s)", err)
|
||||
_ = ch.Close()
|
||||
continue
|
||||
}
|
||||
ctrlAccepter.network.ConnectRouter(r)
|
||||
ctrlAccepter.network.ValidateTerminators(r)
|
||||
|
||||
log.Infof("accepted new router connection [r/%s]", r.Id)
|
||||
}
|
||||
|
||||
} else {
|
||||
log.Errorf("error accepting (%s)", err)
|
||||
_, err := channel.NewChannel("ctrl", self.listener, self.options)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("error accepting control channel connection")
|
||||
if err.Error() == "closed" {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *CtrlAccepter) Bind(binding channel.Binding) error {
|
||||
log := pfxlog.Logger()
|
||||
|
||||
binding.GetChannel().SetLogicalName(binding.GetChannel().Id().Token)
|
||||
ch := binding.GetChannel()
|
||||
|
||||
if r, err := self.network.GetRouter(ch.Id().Token); err == nil {
|
||||
if ch.Underlay().Headers() != nil {
|
||||
if versionValue, found := ch.Underlay().Headers()[channel.HelloVersionHeader]; found {
|
||||
if versionInfo, err := self.network.VersionProvider.EncoderDecoder().Decode(versionValue); err == nil {
|
||||
r.VersionInfo = versionInfo
|
||||
} else {
|
||||
return errors.Wrap(err, "could not parse version info from router hello, closing router connection")
|
||||
}
|
||||
} else {
|
||||
return errors.New("no version info header, closing router connection")
|
||||
}
|
||||
|
||||
if listenerValue, found := ch.Underlay().Headers()[channel.HelloRouterAdvertisementsHeader]; found {
|
||||
listenerString := string(listenerValue)
|
||||
r.AdvertisedListener = listenerString
|
||||
} else {
|
||||
log.Warn("no advertised listeners")
|
||||
}
|
||||
} else {
|
||||
log.Warn("no attributes provided")
|
||||
}
|
||||
|
||||
r.Control = ch
|
||||
if err := binding.Bind(newBindHandler(r, self.network, self.xctrls)); err != nil {
|
||||
return errors.Wrap(err, "error binding router")
|
||||
}
|
||||
|
||||
if self.traceHandler != nil {
|
||||
binding.AddPeekHandler(self.traceHandler)
|
||||
}
|
||||
|
||||
self.network.ConnectRouter(r)
|
||||
self.network.ValidateTerminators(r)
|
||||
|
||||
log.Infof("accepted new router connection [r/%s]", r.Id)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
package handler_ctrl
|
||||
|
||||
import (
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/channel/latency"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xctrl"
|
||||
metrics2 "github.com/openziti/fabric/router/metrics"
|
||||
"github.com/openziti/fabric/trace"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/metrics"
|
||||
"time"
|
||||
)
|
||||
@@ -32,61 +33,67 @@ type bindHandler struct {
|
||||
xctrls []xctrl.Xctrl
|
||||
}
|
||||
|
||||
func newBindHandler(router *network.Router, network *network.Network, xctrls []xctrl.Xctrl) *bindHandler {
|
||||
func newBindHandler(router *network.Router, network *network.Network, xctrls []xctrl.Xctrl) channel.BindHandler {
|
||||
return &bindHandler{router: router, network: network, xctrls: xctrls}
|
||||
}
|
||||
|
||||
func (self *bindHandler) BindChannel(ch channel.Channel) error {
|
||||
func (self *bindHandler) BindChannel(binding channel.Binding) error {
|
||||
traceDispatchWrapper := trace.NewDispatchWrapper(self.network.GetEventDispatcher().Dispatch)
|
||||
ch.SetLogicalName(self.router.Id)
|
||||
ch.AddReceiveHandler(newCircuitRequestHandler(self.router, self.network))
|
||||
ch.AddReceiveHandler(newRouteResultHandler(self.network, self.router))
|
||||
ch.AddReceiveHandler(newCircuitConfirmationHandler(self.network, self.router))
|
||||
ch.AddReceiveHandler(newCreateTerminatorHandler(self.network, self.router))
|
||||
ch.AddReceiveHandler(newRemoveTerminatorHandler(self.network))
|
||||
ch.AddReceiveHandler(newUpdateTerminatorHandler(self.network))
|
||||
ch.AddReceiveHandler(newLinkHandler(self.router, self.network))
|
||||
ch.AddReceiveHandler(newVerifyLinkHandler(self.router, self.network))
|
||||
ch.AddReceiveHandler(newFaultHandler(self.router, self.network))
|
||||
ch.AddReceiveHandler(newMetricsHandler(self.network))
|
||||
ch.AddReceiveHandler(newTraceHandler(traceDispatchWrapper))
|
||||
ch.AddReceiveHandler(newInspectHandler(self.network))
|
||||
ch.AddReceiveHandler(newPingHandler())
|
||||
ch.AddPeekHandler(trace.NewChannelPeekHandler(self.network.GetAppId(), ch, self.network.GetTraceController(), traceDispatchWrapper))
|
||||
ch.AddPeekHandler(metrics2.NewCtrlChannelPeekHandler(self.router.Id, self.network.GetMetricsRegistry()))
|
||||
binding.AddTypedReceiveHandler(newCircuitRequestHandler(self.router, self.network))
|
||||
binding.AddTypedReceiveHandler(newRouteResultHandler(self.network, self.router))
|
||||
binding.AddTypedReceiveHandler(newCircuitConfirmationHandler(self.network, self.router))
|
||||
binding.AddTypedReceiveHandler(newCreateTerminatorHandler(self.network, self.router))
|
||||
binding.AddTypedReceiveHandler(newRemoveTerminatorHandler(self.network))
|
||||
binding.AddTypedReceiveHandler(newUpdateTerminatorHandler(self.network))
|
||||
binding.AddTypedReceiveHandler(newLinkHandler(self.router, self.network))
|
||||
binding.AddTypedReceiveHandler(newVerifyLinkHandler(self.router, self.network))
|
||||
binding.AddTypedReceiveHandler(newFaultHandler(self.router, self.network))
|
||||
binding.AddTypedReceiveHandler(newMetricsHandler(self.network))
|
||||
binding.AddTypedReceiveHandler(newTraceHandler(traceDispatchWrapper))
|
||||
binding.AddTypedReceiveHandler(newInspectHandler(self.network))
|
||||
binding.AddTypedReceiveHandler(newPingHandler())
|
||||
binding.AddPeekHandler(trace.NewChannelPeekHandler(self.network.GetAppId(), binding.GetChannel(), self.network.GetTraceController(), traceDispatchWrapper))
|
||||
binding.AddPeekHandler(metrics2.NewCtrlChannelPeekHandler(self.router.Id, self.network.GetMetricsRegistry()))
|
||||
|
||||
if self.router.VersionInfo.HasMinimumVersion("0.18.7") {
|
||||
latencyHandler := &ctrlChannelLatencyHandler{
|
||||
histogram: self.network.GetMetricsRegistry().Histogram("ctrl." + self.router.Id + ".latency"),
|
||||
roundTripHistogram: self.network.GetMetricsRegistry().Histogram("ctrl.latency:" + self.router.Id),
|
||||
queueTimeHistogram: self.network.GetMetricsRegistry().Histogram("ctrl.queue_time:" + self.router.Id),
|
||||
}
|
||||
metrics.AddLatencyProbe(ch, self.network.GetOptions().CtrlChanLatencyInterval, latencyHandler)
|
||||
latency.AddLatencyProbe(binding.GetChannel(), binding, self.network.GetOptions().CtrlChanLatencyInterval/time.Duration(10), 10, latencyHandler)
|
||||
}
|
||||
|
||||
xctrlDone := make(chan struct{})
|
||||
for _, x := range self.xctrls {
|
||||
if err := ch.Bind(x); err != nil {
|
||||
if err := binding.Bind(x); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := x.Run(ch, self.network.GetDb(), xctrlDone); err != nil {
|
||||
if err := x.Run(binding.GetChannel(), self.network.GetDb(), xctrlDone); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(self.xctrls) > 0 {
|
||||
ch.AddCloseHandler(newXctrlCloseHandler(xctrlDone))
|
||||
binding.AddCloseHandler(newXctrlCloseHandler(xctrlDone))
|
||||
}
|
||||
|
||||
ch.AddCloseHandler(newCloseHandler(self.router, self.network))
|
||||
binding.AddCloseHandler(newCloseHandler(self.router, self.network))
|
||||
return nil
|
||||
}
|
||||
|
||||
type ctrlChannelLatencyHandler struct {
|
||||
histogram metrics.Histogram
|
||||
roundTripHistogram metrics.Histogram
|
||||
queueTimeHistogram metrics.Histogram
|
||||
}
|
||||
|
||||
func (self *ctrlChannelLatencyHandler) LatencyReported(latency time.Duration) {
|
||||
self.histogram.Update(latency.Nanoseconds())
|
||||
func (self *ctrlChannelLatencyHandler) LatencyReported(latencyType latency.Type, elapsed time.Duration) {
|
||||
if latencyType == latency.RoundTripType {
|
||||
self.roundTripHistogram.Update(elapsed.Nanoseconds())
|
||||
} else if latencyType == latency.BeforeSendType {
|
||||
self.queueTimeHistogram.Update(elapsed.Nanoseconds())
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ctrlChannelLatencyHandler) ChannelClosed() {
|
||||
self.histogram.Dispose()
|
||||
self.roundTripHistogram.Dispose()
|
||||
self.queueTimeHistogram.Dispose()
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/ctrl_msg"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ package handler_ctrl
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/ctrl_msg"
|
||||
"github.com/openziti/fabric/logcontext"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"time"
|
||||
)
|
||||
@@ -66,7 +66,7 @@ func (h *circuitRequestHandler) HandleReceive(msg *channel.Message, ch channel.C
|
||||
responseMsg.Headers[int32(k)] = v
|
||||
}
|
||||
|
||||
if err := h.r.Control.Send(responseMsg.WithTimeout(10 * time.Second)); err != nil {
|
||||
if err := responseMsg.WithTimeout(10 * time.Second).Send(h.r.Control); err != nil {
|
||||
log.Errorf("unable to respond with success to create circuit request for circuit %v (%s)", circuit.Id, err)
|
||||
if err := h.network.RemoveCircuit(circuit.Id, true); err != nil {
|
||||
log.Errorf("unable to remove circuit %v (%v)", circuit.Id, err)
|
||||
|
||||
@@ -18,8 +18,8 @@ package handler_ctrl
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/foundation/channel"
|
||||
)
|
||||
|
||||
type closeHandler struct {
|
||||
|
||||
@@ -21,9 +21,9 @@ import (
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xctrl"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"github.com/openziti/foundation/util/stringz"
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"math"
|
||||
)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ package handler_ctrl
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
)
|
||||
|
||||
type inspectHandler struct {
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type linkHandler struct {
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/metrics"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/metrics/metrics_pb"
|
||||
)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package handler_ctrl
|
||||
|
||||
import (
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type pingHandler struct{}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type removeTerminatorHandler struct {
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/fabric/ctrl_msg"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/fabric/trace"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
trace_pb "github.com/openziti/foundation/trace/pb"
|
||||
)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"math"
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type verifyLinkHandler struct {
|
||||
|
||||
@@ -18,16 +18,16 @@ package handler_mgmt
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type MgmtAccepter struct {
|
||||
listener channel2.UnderlayListener
|
||||
options *channel2.Options
|
||||
listener channel.UnderlayListener
|
||||
options *channel.Options
|
||||
}
|
||||
|
||||
func NewMgmtAccepter(listener channel2.UnderlayListener,
|
||||
options *channel2.Options) *MgmtAccepter {
|
||||
func NewMgmtAccepter(listener channel.UnderlayListener,
|
||||
options *channel.Options) *MgmtAccepter {
|
||||
return &MgmtAccepter{
|
||||
listener: listener,
|
||||
options: options,
|
||||
@@ -40,7 +40,7 @@ func (mgmtAccepter *MgmtAccepter) Run() {
|
||||
defer log.Warn("exited")
|
||||
|
||||
for {
|
||||
ch, err := channel2.NewChannel("mgmt", mgmtAccepter.listener, mgmtAccepter.options)
|
||||
ch, err := channel.NewChannel("mgmt", mgmtAccepter.listener, mgmtAccepter.options)
|
||||
if err == nil {
|
||||
log.Debugf("accepted mgmt connection [%s]", ch.Id().Token)
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package handler_mgmt
|
||||
|
||||
import (
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xmgmt"
|
||||
"github.com/openziti/fabric/trace"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type BindHandler struct {
|
||||
@@ -28,62 +28,62 @@ type BindHandler struct {
|
||||
xmgmts []xmgmt.Xmgmt
|
||||
}
|
||||
|
||||
func NewBindHandler(network *network.Network, xmgmts []xmgmt.Xmgmt) *BindHandler {
|
||||
func NewBindHandler(network *network.Network, xmgmts []xmgmt.Xmgmt) channel.BindHandler {
|
||||
return &BindHandler{network: network, xmgmts: xmgmts}
|
||||
}
|
||||
|
||||
func (bindHandler *BindHandler) BindChannel(ch channel2.Channel) error {
|
||||
func (bindHandler *BindHandler) BindChannel(binding channel.Binding) error {
|
||||
network := bindHandler.network
|
||||
ch.AddReceiveHandler(newCreateRouterHandler(network))
|
||||
ch.AddReceiveHandler(newCreateServiceHandler(network))
|
||||
ch.AddReceiveHandler(newGetServiceHandler(network))
|
||||
ch.AddReceiveHandler(newInspectHandler(network))
|
||||
ch.AddReceiveHandler(newListLinksHandler(network))
|
||||
ch.AddReceiveHandler(newListRoutersHandler(network))
|
||||
ch.AddReceiveHandler(newListServicesHandler(network))
|
||||
ch.AddReceiveHandler(newListCircuitsHandler(network))
|
||||
ch.AddReceiveHandler(newRemoveRouterHandler(network))
|
||||
ch.AddReceiveHandler(newRemoveServiceHandler(network))
|
||||
ch.AddReceiveHandler(newRemoveCircuitHandler(network))
|
||||
ch.AddReceiveHandler(newSetLinkCostHandler(network))
|
||||
ch.AddReceiveHandler(newSetLinkDownHandler(network))
|
||||
binding.AddTypedReceiveHandler(newCreateRouterHandler(network))
|
||||
binding.AddTypedReceiveHandler(newCreateServiceHandler(network))
|
||||
binding.AddTypedReceiveHandler(newGetServiceHandler(network))
|
||||
binding.AddTypedReceiveHandler(newInspectHandler(network))
|
||||
binding.AddTypedReceiveHandler(newListLinksHandler(network))
|
||||
binding.AddTypedReceiveHandler(newListRoutersHandler(network))
|
||||
binding.AddTypedReceiveHandler(newListServicesHandler(network))
|
||||
binding.AddTypedReceiveHandler(newListCircuitsHandler(network))
|
||||
binding.AddTypedReceiveHandler(newRemoveRouterHandler(network))
|
||||
binding.AddTypedReceiveHandler(newRemoveServiceHandler(network))
|
||||
binding.AddTypedReceiveHandler(newRemoveCircuitHandler(network))
|
||||
binding.AddTypedReceiveHandler(newSetLinkCostHandler(network))
|
||||
binding.AddTypedReceiveHandler(newSetLinkDownHandler(network))
|
||||
|
||||
ch.AddReceiveHandler(newCreateTerminatorHandler(network))
|
||||
ch.AddReceiveHandler(newRemoveTerminatorHandler(network))
|
||||
ch.AddReceiveHandler(newGetTerminatorHandler(network))
|
||||
ch.AddReceiveHandler(newListTerminatorsHandler(network))
|
||||
ch.AddReceiveHandler(newSetTerminatorCostHandler(network))
|
||||
binding.AddTypedReceiveHandler(newCreateTerminatorHandler(network))
|
||||
binding.AddTypedReceiveHandler(newRemoveTerminatorHandler(network))
|
||||
binding.AddTypedReceiveHandler(newGetTerminatorHandler(network))
|
||||
binding.AddTypedReceiveHandler(newListTerminatorsHandler(network))
|
||||
binding.AddTypedReceiveHandler(newSetTerminatorCostHandler(network))
|
||||
|
||||
streamMetricHandler := newStreamMetricsHandler(network)
|
||||
ch.AddReceiveHandler(streamMetricHandler)
|
||||
ch.AddCloseHandler(streamMetricHandler)
|
||||
binding.AddTypedReceiveHandler(streamMetricHandler)
|
||||
binding.AddCloseHandler(streamMetricHandler)
|
||||
|
||||
streamCircuitsHandler := newStreamCircuitsHandler(network)
|
||||
ch.AddReceiveHandler(streamCircuitsHandler)
|
||||
ch.AddCloseHandler(streamCircuitsHandler)
|
||||
binding.AddTypedReceiveHandler(streamCircuitsHandler)
|
||||
binding.AddCloseHandler(streamCircuitsHandler)
|
||||
|
||||
streamTracesHandler := newStreamTracesHandler(network)
|
||||
ch.AddReceiveHandler(streamTracesHandler)
|
||||
ch.AddCloseHandler(streamTracesHandler)
|
||||
binding.AddTypedReceiveHandler(streamTracesHandler)
|
||||
binding.AddCloseHandler(streamTracesHandler)
|
||||
|
||||
ch.AddReceiveHandler(newTogglePipeTracesHandler(network))
|
||||
binding.AddTypedReceiveHandler(newTogglePipeTracesHandler(network))
|
||||
|
||||
traceDispatchWrapper := trace.NewDispatchWrapper(network.GetEventDispatcher().Dispatch)
|
||||
ch.AddPeekHandler(trace.NewChannel2PeekHandler(network.GetAppId(), ch, network.GetTraceController(), traceDispatchWrapper))
|
||||
binding.AddPeekHandler(trace.NewChannelPeekHandler(network.GetAppId(), binding.GetChannel(), network.GetTraceController(), traceDispatchWrapper))
|
||||
|
||||
ch.AddReceiveHandler(newSnapshotDbHandler(network))
|
||||
binding.AddTypedReceiveHandler(newSnapshotDbHandler(network))
|
||||
|
||||
xmgmtDone := make(chan struct{})
|
||||
for _, x := range bindHandler.xmgmts {
|
||||
if err := ch.Bind(x); err != nil {
|
||||
if err := binding.Bind(x); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := x.Run(ch, xmgmtDone); err != nil {
|
||||
if err := x.Run(binding.GetChannel(), xmgmtDone); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(bindHandler.xmgmts) > 0 {
|
||||
ch.AddCloseHandler(newXmgmtCloseHandler(xmgmtDone))
|
||||
binding.AddCloseHandler(newXmgmtCloseHandler(xmgmtDone))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -18,18 +18,18 @@ package handler_mgmt
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type xmgmtCloseHandler struct {
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
func newXmgmtCloseHandler(done chan struct{}) channel2.CloseHandler {
|
||||
func newXmgmtCloseHandler(done chan struct{}) channel.CloseHandler {
|
||||
return &xmgmtCloseHandler{done: done}
|
||||
}
|
||||
|
||||
func (h *xmgmtCloseHandler) HandleClose(ch channel2.Channel) {
|
||||
func (h *xmgmtCloseHandler) HandleClose(ch channel.Channel) {
|
||||
pfxlog.ContextLogger(ch.Label()).Debug("closing Xmgmt instances")
|
||||
close(h.done)
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package handler_mgmt
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/util/errorz"
|
||||
"github.com/pkg/errors"
|
||||
@@ -37,7 +37,7 @@ func NewConnectHandler(identity identity.Identity, network *network.Network) *Co
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ConnectHandler) HandleConnection(hello *channel2.Hello, certificates []*x509.Certificate) error {
|
||||
func (self *ConnectHandler) HandleConnection(hello *channel.Hello, certificates []*x509.Certificate) error {
|
||||
if len(certificates) == 0 {
|
||||
return errors.New("no certificates provided, unable to verify dialer")
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type createRouterHandler struct {
|
||||
@@ -37,7 +37,7 @@ func (h *createRouterHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_CreateRouterRequestType)
|
||||
}
|
||||
|
||||
func (h *createRouterHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *createRouterHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
create := &mgmt_pb.CreateRouterRequest{}
|
||||
@@ -45,11 +45,11 @@ func (h *createRouterHandler) HandleReceive(msg *channel2.Message, ch channel2.C
|
||||
r := network.NewRouter(create.Router.Id, create.Router.Name, create.Router.Fingerprint)
|
||||
if err := h.network.CreateRouter(r); err == nil {
|
||||
log.Infof("created router [r/%s] with fingerprint [%s]", r.Id, create.Router.Fingerprint)
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ package handler_mgmt
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type createServiceHandler struct {
|
||||
@@ -37,7 +37,7 @@ func (h *createServiceHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_CreateServiceRequestType)
|
||||
}
|
||||
|
||||
func (h *createServiceHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *createServiceHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
cs := &mgmt_pb.CreateServiceRequest{}
|
||||
err := proto.Unmarshal(msg.Body, cs)
|
||||
if err == nil {
|
||||
@@ -52,17 +52,17 @@ func (h *createServiceHandler) HandleReceive(msg *channel2.Message, ch channel2.
|
||||
for _, terminator := range cs.Service.Terminators {
|
||||
modelTerminator, err := toModelTerminator(h.network, terminator)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
service.Terminators = append(service.Terminators, modelTerminator)
|
||||
}
|
||||
if err = h.network.Services.Create(service); err == nil {
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ package handler_mgmt
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/pkg/errors"
|
||||
"math"
|
||||
)
|
||||
@@ -40,21 +40,21 @@ func (h *createTerminatorHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_CreateTerminatorRequestType)
|
||||
}
|
||||
|
||||
func (h *createTerminatorHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *createTerminatorHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
cs := &mgmt_pb.CreateTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, cs); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
terminator, err := toModelTerminator(h.network, cs.Terminator)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
if id, err := h.network.Terminators.Create(terminator); err == nil {
|
||||
handler_common.SendChannel2Success(msg, ch, id)
|
||||
handler_common.SendSuccess(msg, ch, id)
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type getServiceHandler struct {
|
||||
@@ -37,26 +37,26 @@ func (h *getServiceHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_GetServiceRequestType)
|
||||
}
|
||||
|
||||
func (h *getServiceHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *getServiceHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
rs := &mgmt_pb.GetServiceRequest{}
|
||||
err := proto.Unmarshal(msg.Body, rs)
|
||||
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
response := &mgmt_pb.GetServiceResponse{}
|
||||
svc, err := h.network.Services.Read(rs.ServiceId)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
response.Service = toApiService(svc)
|
||||
body, err := proto.Marshal(response)
|
||||
if err == nil {
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_GetServiceResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_GetServiceResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
ch.Send(responseMsg)
|
||||
} else {
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type getTerminatorHandler struct {
|
||||
@@ -37,23 +37,23 @@ func (h *getTerminatorHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_GetTerminatorRequestType)
|
||||
}
|
||||
|
||||
func (h *getTerminatorHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *getTerminatorHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
rs := &mgmt_pb.GetTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, rs); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
response := &mgmt_pb.GetTerminatorResponse{}
|
||||
terminator, err := h.network.Terminators.Read(rs.TerminatorId)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
response.Terminator = toApiTerminator(terminator)
|
||||
body, err := proto.Marshal(response)
|
||||
if err == nil {
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_GetTerminatorResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_GetTerminatorResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
if err = ch.Send(responseMsg); err != nil {
|
||||
pfxlog.ContextLogger(ch.Label()).Errorf("unexpected error (%s)", err)
|
||||
|
||||
@@ -20,9 +20,9 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type inspectHandler struct {
|
||||
@@ -37,7 +37,7 @@ func (*inspectHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_InspectRequestType)
|
||||
}
|
||||
|
||||
func (handler *inspectHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (handler *inspectHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
go func() {
|
||||
response := &mgmt_pb.InspectResponse{}
|
||||
request := &mgmt_pb.InspectRequest{}
|
||||
@@ -63,7 +63,7 @@ func (handler *inspectHandler) HandleReceive(msg *channel2.Message, ch channel2.
|
||||
return
|
||||
}
|
||||
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_InspectResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_InspectResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
if err := ch.Send(responseMsg); err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error sending InspectResponse (%s)", err)
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type listCircuitsHandler struct {
|
||||
@@ -37,10 +37,10 @@ func (h *listCircuitsHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_ListCircuitsRequestType)
|
||||
}
|
||||
|
||||
func (h *listCircuitsHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *listCircuitsHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
list := &mgmt_pb.ListCircuitsRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, list); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ func (h *listCircuitsHandler) HandleReceive(msg *channel2.Message, ch channel2.C
|
||||
}
|
||||
body, err := proto.Marshal(response)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListCircuitsResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListCircuitsResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
if err := ch.Send(responseMsg); err != nil {
|
||||
pfxlog.ContextLogger(ch.Label()).Errorf("unexpected error sending response (%s)", err)
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type listLinksHandler struct {
|
||||
@@ -37,10 +37,10 @@ func (h *listLinksHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_ListLinksRequestType)
|
||||
}
|
||||
|
||||
func (h *listLinksHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *listLinksHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
list := &mgmt_pb.ListLinksRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, list); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ func (h *listLinksHandler) HandleReceive(msg *channel2.Message, ch channel2.Chan
|
||||
|
||||
body, err := proto.Marshal(response)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListLinksResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListLinksResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
if err := ch.Send(responseMsg); err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error sending response (%s)", err)
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/util/stringz"
|
||||
"reflect"
|
||||
)
|
||||
@@ -40,7 +40,7 @@ func (h *listRoutersHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_ListRoutersRequestType)
|
||||
}
|
||||
|
||||
func (h *listRoutersHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *listRoutersHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
list := &mgmt_pb.ListRoutersRequest{}
|
||||
@@ -52,7 +52,7 @@ func (h *listRoutersHandler) HandleReceive(msg *channel2.Message, ch channel2.Ch
|
||||
router, ok := entity.(*network.Router)
|
||||
if !ok {
|
||||
errorMsg := fmt.Sprintf("unexpected result in router list of type: %v", reflect.TypeOf(entity))
|
||||
handler_common.SendChannel2Failure(msg, ch, errorMsg)
|
||||
handler_common.SendFailure(msg, ch, errorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -76,18 +76,18 @@ func (h *listRoutersHandler) HandleReceive(msg *channel2.Message, ch channel2.Ch
|
||||
}
|
||||
|
||||
if body, err := proto.Marshal(response); err == nil {
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListRoutersResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListRoutersResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
if err := ch.Send(responseMsg); err != nil {
|
||||
pfxlog.ContextLogger(ch.Label()).Errorf("unexpected error sending response (%s)", err)
|
||||
}
|
||||
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ func (h *listServicesHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_ListServicesRequestType)
|
||||
}
|
||||
|
||||
func (h *listServicesHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *listServicesHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
ls := &mgmt_pb.ListServicesRequest{}
|
||||
err := proto.Unmarshal(msg.Body, ls)
|
||||
if err == nil {
|
||||
@@ -50,7 +50,7 @@ func (h *listServicesHandler) HandleReceive(msg *channel2.Message, ch channel2.C
|
||||
service, ok := entity.(*network.Service)
|
||||
if !ok {
|
||||
errorMsg := fmt.Sprintf("unexpected result in service list of type: %v", reflect.TypeOf(entity))
|
||||
handler_common.SendChannel2Failure(msg, ch, errorMsg)
|
||||
handler_common.SendFailure(msg, ch, errorMsg)
|
||||
return
|
||||
}
|
||||
response.Services = append(response.Services, toApiService(service))
|
||||
@@ -58,19 +58,19 @@ func (h *listServicesHandler) HandleReceive(msg *channel2.Message, ch channel2.C
|
||||
|
||||
body, err := proto.Marshal(response)
|
||||
if err == nil {
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListServicesResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListServicesResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
if err := ch.Send(responseMsg); err != nil {
|
||||
pfxlog.ContextLogger(ch.Label()).Errorf("unexpected error sending response (%s)", err)
|
||||
}
|
||||
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
@@ -39,10 +39,10 @@ func (h *listTerminatorsHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_ListTerminatorsRequestType)
|
||||
}
|
||||
|
||||
func (h *listTerminatorsHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *listTerminatorsHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
ls := &mgmt_pb.ListTerminatorsRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, ls); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
response := &mgmt_pb.ListTerminatorsResponse{Terminators: make([]*mgmt_pb.Terminator, 0)}
|
||||
@@ -53,7 +53,7 @@ func (h *listTerminatorsHandler) HandleReceive(msg *channel2.Message, ch channel
|
||||
terminator, ok := entity.(*network.Terminator)
|
||||
if !ok {
|
||||
errorMsg := fmt.Sprintf("unexpected result in terminator list of type: %v", reflect.TypeOf(entity))
|
||||
handler_common.SendChannel2Failure(msg, ch, errorMsg)
|
||||
handler_common.SendFailure(msg, ch, errorMsg)
|
||||
return
|
||||
}
|
||||
response.Terminators = append(response.Terminators, toApiTerminator(terminator))
|
||||
@@ -61,15 +61,15 @@ func (h *listTerminatorsHandler) HandleReceive(msg *channel2.Message, ch channel
|
||||
|
||||
body, err := proto.Marshal(response)
|
||||
if err == nil {
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListTerminatorsResponseType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListTerminatorsResponseType), body)
|
||||
responseMsg.ReplyTo(msg)
|
||||
if err := ch.Send(responseMsg); err != nil {
|
||||
pfxlog.ContextLogger(ch.Label()).Errorf("unexpected error sending response (%s)", err)
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type removeCircuitHandler struct {
|
||||
@@ -37,16 +37,16 @@ func (handler *removeCircuitHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_RemoveCircuitRequestType)
|
||||
}
|
||||
|
||||
func (handler *removeCircuitHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (handler *removeCircuitHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
request := &mgmt_pb.RemoveCircuitRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err == nil {
|
||||
if err := handler.network.RemoveCircuit(request.CircuitId, request.Now); err == nil {
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
pfxlog.Logger().WithError(err).WithField("circuitId", request.CircuitId).Error("unexpected error removing circuit")
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type removeRouterHandler struct {
|
||||
@@ -37,25 +37,25 @@ func (h *removeRouterHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_RemoveRouterRequestType)
|
||||
}
|
||||
|
||||
func (h *removeRouterHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *removeRouterHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
request := &mgmt_pb.RemoveRouterRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
_, err := h.network.Routers.Read(request.RouterId)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.network.Routers.Delete(request.RouterId); err == nil {
|
||||
log.Infof("removed router [r/%v]", request.RouterId)
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type removeServiceHandler struct {
|
||||
@@ -37,25 +37,25 @@ func (h *removeServiceHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_RemoveServiceRequestType)
|
||||
}
|
||||
|
||||
func (h *removeServiceHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *removeServiceHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
request := &mgmt_pb.RemoveServiceRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
_, err := h.network.Services.Read(request.ServiceId)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.network.Services.Delete(request.ServiceId); err == nil {
|
||||
log.Infof("removed service [s/%v]", request.ServiceId)
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type removeTerminatorHandler struct {
|
||||
@@ -37,25 +37,25 @@ func (h *removeTerminatorHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_RemoveTerminatorRequestType)
|
||||
}
|
||||
|
||||
func (h *removeTerminatorHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *removeTerminatorHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
request := &mgmt_pb.RemoveTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
_, err := h.network.Terminators.Read(request.TerminatorId)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.network.Terminators.Delete(request.TerminatorId); err == nil {
|
||||
log.Infof("removed terminator [e/%s]", request.TerminatorId)
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type setLinkCostHandler struct {
|
||||
@@ -38,7 +38,7 @@ func (h *setLinkCostHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_SetLinkCostRequestType)
|
||||
}
|
||||
|
||||
func (h *setLinkCostHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *setLinkCostHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
set := &mgmt_pb.SetLinkCostRequest{}
|
||||
@@ -47,11 +47,11 @@ func (h *setLinkCostHandler) HandleReceive(msg *channel2.Message, ch channel2.Ch
|
||||
l.SetStaticCost(set.Cost)
|
||||
h.network.LinkChanged(l)
|
||||
log.Infof("set cost of link [l/%s] to [%d]", set.LinkId, set.Cost)
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, fmt.Sprintf("unknown link [l/%s]", set.LinkId))
|
||||
handler_common.SendFailure(msg, ch, fmt.Sprintf("unknown link [l/%s]", set.LinkId))
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type setLinkDownHandler struct {
|
||||
@@ -38,7 +38,7 @@ func (h *setLinkDownHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_SetLinkDownRequestType)
|
||||
}
|
||||
|
||||
func (h *setLinkDownHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *setLinkDownHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
log := pfxlog.ContextLogger(ch.Label())
|
||||
|
||||
set := &mgmt_pb.SetLinkDownRequest{}
|
||||
@@ -47,11 +47,11 @@ func (h *setLinkDownHandler) HandleReceive(msg *channel2.Message, ch channel2.Ch
|
||||
l.SetDown(set.Down)
|
||||
h.network.LinkChanged(l)
|
||||
log.Infof("set down state of link [l/%s] to [%t]", set.LinkId, set.Down)
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, fmt.Sprintf("unknown link [l/%s]", set.LinkId))
|
||||
handler_common.SendFailure(msg, ch, fmt.Sprintf("unknown link [l/%s]", set.LinkId))
|
||||
}
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ package handler_mgmt
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"math"
|
||||
)
|
||||
@@ -41,16 +41,16 @@ func (h *setTerminatorCostHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_SetTerminatorCostRequestType)
|
||||
}
|
||||
|
||||
func (h *setTerminatorCostHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *setTerminatorCostHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
request := &mgmt_pb.SetTerminatorCostRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
terminator, err := h.network.Terminators.Read(request.TerminatorId)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func (h *setTerminatorCostHandler) HandleReceive(msg *channel2.Message, ch chann
|
||||
} else if request.Precedence == mgmt_pb.TerminatorPrecedence_Failed {
|
||||
precedence = xt.Precedences.Failed
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, fmt.Sprintf("invalid precedence: %v", request.Precedence))
|
||||
handler_common.SendFailure(msg, ch, fmt.Sprintf("invalid precedence: %v", request.Precedence))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (h *setTerminatorCostHandler) HandleReceive(msg *channel2.Message, ch chann
|
||||
var staticCost uint16
|
||||
if request.UpdateMask&int32(mgmt_pb.TerminatorChangeMask_StaticCost) != 0 {
|
||||
if request.StaticCost > math.MaxUint16 {
|
||||
handler_common.SendChannel2Failure(msg, ch, fmt.Sprintf("invalid static cost %v. Must be less than %v", request.StaticCost, math.MaxUint16))
|
||||
handler_common.SendFailure(msg, ch, fmt.Sprintf("invalid static cost %v. Must be less than %v", request.StaticCost, math.MaxUint16))
|
||||
return
|
||||
}
|
||||
staticCost = uint16(request.StaticCost)
|
||||
@@ -80,7 +80,7 @@ func (h *setTerminatorCostHandler) HandleReceive(msg *channel2.Message, ch chann
|
||||
var dynamicCost uint16
|
||||
if request.UpdateMask&int32(mgmt_pb.TerminatorChangeMask_DynamicCost) != 0 {
|
||||
if request.DynamicCost > math.MaxUint16 {
|
||||
handler_common.SendChannel2Failure(msg, ch, fmt.Sprintf("invalid dynamic cost %v. Must be less than %v", request.DynamicCost, math.MaxUint16))
|
||||
handler_common.SendFailure(msg, ch, fmt.Sprintf("invalid dynamic cost %v. Must be less than %v", request.DynamicCost, math.MaxUint16))
|
||||
return
|
||||
}
|
||||
dynamicCost = uint16(request.DynamicCost)
|
||||
@@ -103,7 +103,7 @@ func (h *setTerminatorCostHandler) HandleReceive(msg *channel2.Message, ch chann
|
||||
}
|
||||
|
||||
if err := h.network.Terminators.Patch(terminator, checker); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -112,5 +112,5 @@ func (h *setTerminatorCostHandler) HandleReceive(msg *channel2.Message, ch chann
|
||||
xt.GlobalCosts().SetDynamicCost(request.TerminatorId, dynamicCost)
|
||||
}
|
||||
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package handler_mgmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type snapshotDbHandler struct {
|
||||
@@ -22,10 +22,10 @@ func (h *snapshotDbHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_SnapshotDbRequestType)
|
||||
}
|
||||
|
||||
func (h *snapshotDbHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (h *snapshotDbHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
if err := h.network.SnapshotDatabase(); err == nil {
|
||||
handler_common.SendChannel2Success(msg, ch, "")
|
||||
handler_common.SendSuccess(msg, ch, "")
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, fmt.Sprintf("error snapshotting db: (%v)", err))
|
||||
handler_common.SendFailure(msg, ch, fmt.Sprintf("error snapshotting db: (%v)", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/events"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
type streamCircuitsHandler struct {
|
||||
@@ -39,10 +39,10 @@ func (*streamCircuitsHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_StreamCircuitsRequestType)
|
||||
}
|
||||
|
||||
func (handler *streamCircuitsHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (handler *streamCircuitsHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
request := &mgmt_pb.StreamCircuitsRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ func (handler *streamCircuitsHandler) HandleReceive(msg *channel2.Message, ch ch
|
||||
events.AddCircuitEventHandler(circuitsStreamHandler)
|
||||
}
|
||||
|
||||
func (handler *streamCircuitsHandler) HandleClose(ch channel2.Channel) {
|
||||
func (handler *streamCircuitsHandler) HandleClose(ch channel.Channel) {
|
||||
for _, listener := range handler.streamHandlers {
|
||||
events.RemoveCircuitEventHandler(listener)
|
||||
}
|
||||
}
|
||||
|
||||
type CircuitsStreamHandler struct {
|
||||
ch channel2.Channel
|
||||
ch channel.Channel
|
||||
}
|
||||
|
||||
func (handler *CircuitsStreamHandler) CircuitCreated(circuitId string, clientId string, serviceId string, path *network.Path) {
|
||||
@@ -97,7 +97,7 @@ func (handler *CircuitsStreamHandler) sendEvent(event *mgmt_pb.StreamCircuitsEve
|
||||
return
|
||||
}
|
||||
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_StreamCircuitsEventType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_StreamCircuitsEventType), body)
|
||||
if err := handler.ch.Send(responseMsg); err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error sending StreamMetricsEvent (%s)", err)
|
||||
handler.close()
|
||||
|
||||
@@ -20,11 +20,11 @@ import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
fabricMetrics "github.com/openziti/fabric/metrics"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/metrics"
|
||||
"github.com/openziti/foundation/metrics/metrics_pb"
|
||||
"regexp"
|
||||
@@ -43,16 +43,16 @@ func (*streamMetricsHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_StreamMetricsRequestType)
|
||||
}
|
||||
|
||||
func (handler *streamMetricsHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (handler *streamMetricsHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
request := &mgmt_pb.StreamMetricsRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
filters, err := parseFilters(request)
|
||||
if err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (handler *streamMetricsHandler) HandleReceive(msg *channel2.Message, ch cha
|
||||
fabricMetrics.AddMetricsEventHandler(metricsStreamHandler)
|
||||
}
|
||||
|
||||
func (handler *streamMetricsHandler) HandleClose(channel2.Channel) {
|
||||
func (handler *streamMetricsHandler) HandleClose(channel.Channel) {
|
||||
for _, streamHandler := range handler.streamHandlers {
|
||||
fabricMetrics.RemoveMetricsEventHandler(streamHandler)
|
||||
}
|
||||
@@ -103,7 +103,7 @@ type metricsFilter struct {
|
||||
}
|
||||
|
||||
type MetricsStreamHandler struct {
|
||||
ch channel2.Channel
|
||||
ch channel.Channel
|
||||
filters []*metricsFilter
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ func (handler *MetricsStreamHandler) send(msg *mgmt_pb.StreamMetricsEvent) {
|
||||
return
|
||||
}
|
||||
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_StreamMetricsEventType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_StreamMetricsEventType), body)
|
||||
if err := handler.ch.Send(responseMsg); err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error sending StreamMetricsEvent (%s)", err)
|
||||
handler.close()
|
||||
|
||||
@@ -19,13 +19,12 @@ package handler_mgmt
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/fabric/trace"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
trace_pb "github.com/openziti/foundation/trace/pb"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -43,11 +42,11 @@ func (*traceTogglePipeHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_TogglePipeTracesRequestType)
|
||||
}
|
||||
|
||||
func (handler *traceTogglePipeHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (handler *traceTogglePipeHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
request := &trace_pb.TogglePipeTracesRequest{}
|
||||
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -102,11 +101,11 @@ func (handler *traceTogglePipeHandler) HandleReceive(msg *channel2.Message, ch c
|
||||
handler.complete(msg, ch, result)
|
||||
}
|
||||
|
||||
func (handler *traceTogglePipeHandler) complete(msg *channel2.Message, ch channel2.Channel, result *trace.ToggleResult) {
|
||||
func (handler *traceTogglePipeHandler) complete(msg *channel.Message, ch channel.Channel, result *trace.ToggleResult) {
|
||||
if result.Success {
|
||||
handler_common.SendChannel2Success(msg, ch, result.Message.String())
|
||||
handler_common.SendSuccess(msg, ch, result.Message.String())
|
||||
} else {
|
||||
handler_common.SendChannel2Failure(msg, ch, result.Message.String())
|
||||
handler_common.SendFailure(msg, ch, result.Message.String())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ func getApplyResults(resultChan chan trace.ToggleApplyResult, verbosity trace.To
|
||||
}
|
||||
}
|
||||
|
||||
func handleResponse(router *network.Router, mgmtReq *channel2.Message, msgsCh chan<- *remoteToggleResult, waitGroup *sync.WaitGroup) {
|
||||
func handleResponse(router *network.Router, mgmtReq *channel.Message, msgsCh chan<- *remoteToggleResult, waitGroup *sync.WaitGroup) {
|
||||
defer waitGroup.Done()
|
||||
|
||||
msg := channel.NewMessage(int32(ctrl_pb.ContentType_TogglePipeTracesRequestType), mgmtReq.Body)
|
||||
@@ -145,7 +144,7 @@ func handleResponse(router *network.Router, mgmtReq *channel2.Message, msgsCh ch
|
||||
|
||||
if err != nil {
|
||||
msgsCh <- &remoteToggleResult{false, err.Error()}
|
||||
} else if response.ContentType == channel2.ContentTypeResultType {
|
||||
} else if response.ContentType == channel.ContentTypeResultType {
|
||||
result := channel.UnmarshalResult(response)
|
||||
msgsCh <- &remoteToggleResult{result.Success, result.Message}
|
||||
} else {
|
||||
|
||||
@@ -19,12 +19,12 @@ package handler_mgmt
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/handler_common"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/events"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/fabric/trace"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/trace/pb"
|
||||
)
|
||||
|
||||
@@ -41,10 +41,10 @@ func (*streamTracesHandler) ContentType() int32 {
|
||||
return int32(mgmt_pb.ContentType_StreamTracesRequestType)
|
||||
}
|
||||
|
||||
func (handler *streamTracesHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
|
||||
func (handler *streamTracesHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
|
||||
request := &mgmt_pb.StreamTracesRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err != nil {
|
||||
handler_common.SendChannel2Failure(msg, ch, err.Error())
|
||||
handler_common.SendFailure(msg, ch, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (handler *streamTracesHandler) HandleReceive(msg *channel2.Message, ch chan
|
||||
events.AddTraceEventHandler(eventHandler)
|
||||
}
|
||||
|
||||
func (handler *streamTracesHandler) HandleClose(channel2.Channel) {
|
||||
func (handler *streamTracesHandler) HandleClose(channel.Channel) {
|
||||
for _, streamHandler := range handler.streamHandlers {
|
||||
events.RemoveTraceEventHandler(streamHandler)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func createFilter(request *mgmt_pb.StreamTracesRequest) trace.Filter {
|
||||
}
|
||||
|
||||
type traceEventsHandler struct {
|
||||
ch channel2.Channel
|
||||
ch channel.Channel
|
||||
filter trace.Filter
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (handler *traceEventsHandler) Accept(event *trace_pb.ChannelMessage) {
|
||||
return
|
||||
}
|
||||
|
||||
responseMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_StreamTracesEventType), body)
|
||||
responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_StreamTracesEventType), body)
|
||||
if err := handler.ch.Send(responseMsg); err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error sending ChannelMessage (%s)", err)
|
||||
handler.close()
|
||||
|
||||
@@ -18,8 +18,8 @@ package network
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel/protobufs"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/util/info"
|
||||
)
|
||||
|
||||
@@ -40,7 +40,7 @@ func (network *Network) assemble() {
|
||||
RouterId: missingLink.Dst.Id,
|
||||
}
|
||||
|
||||
if err := missingLink.Src.Control.Send(channel.MarshalTyped(dial)); err != nil {
|
||||
if err := protobufs.MarshalTyped(dial).Send(missingLink.Src.Control); err != nil {
|
||||
log.WithError(err).Error("unexpected error sending dial")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package network
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel/protobufs"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/util/concurrenz"
|
||||
"regexp"
|
||||
"sync"
|
||||
@@ -146,7 +146,8 @@ func (ctx *inspectRequestContext) handleRouterMessaging(router *Router, notifier
|
||||
|
||||
request := &ctrl_pb.InspectRequest{RequestedValues: ctx.requestedValues}
|
||||
resp := &ctrl_pb.InspectResponse{}
|
||||
err := channel.MarshalTyped(request).WithTimeout(ctx.timeout).SendForTypedReply(router.Control, resp)
|
||||
respMsg, err := protobufs.MarshalTyped(request).WithTimeout(ctx.timeout).SendForReply(router.Control)
|
||||
err = protobufs.TypedResponse(resp).Unmarshall(respMsg, err)
|
||||
if err != nil {
|
||||
ctx.appendError(router.Id, err.Error())
|
||||
return
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel/protobufs"
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/fabric/ctrl_msg"
|
||||
@@ -28,7 +29,6 @@ import (
|
||||
fabricMetrics "github.com/openziti/fabric/metrics"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/fabric/trace"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/common"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/metrics"
|
||||
@@ -283,7 +283,7 @@ func (network *Network) ValidateTerminators(r *Router) {
|
||||
Terminators: terminators,
|
||||
}
|
||||
|
||||
if err = r.Control.Send(channel.MarshalTyped(req)); err != nil {
|
||||
if err = protobufs.MarshalTyped(req).Send(r.Control); err != nil {
|
||||
pfxlog.Logger().WithError(err).Error("unexpected error sending ValidateTerminatorsRequest")
|
||||
}
|
||||
}
|
||||
@@ -853,7 +853,7 @@ func sendRoute(r *Router, createMsg *ctrl_pb.Route, timeout time.Duration) (xt.P
|
||||
|
||||
log.Debug("sending create route message")
|
||||
|
||||
msg, err := channel.MarshalTyped(createMsg).WithTimeout(timeout).SendForReply(r.Control)
|
||||
msg, err := protobufs.MarshalTyped(createMsg).WithTimeout(timeout).SendForReply(r.Control)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("timeout", timeout).Error("error sending route message")
|
||||
return nil, err
|
||||
@@ -886,7 +886,7 @@ func sendUnroute(r *Router, circuitId string, now bool) error {
|
||||
CircuitId: circuitId,
|
||||
Now: now,
|
||||
}
|
||||
return r.Control.Send(channel.MarshalTyped(unroute))
|
||||
return protobufs.MarshalTyped(unroute).Send(r.Control)
|
||||
}
|
||||
|
||||
func (network *Network) showOptions() {
|
||||
|
||||
@@ -19,7 +19,7 @@ package network
|
||||
import (
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/common"
|
||||
"github.com/openziti/foundation/transport"
|
||||
"github.com/openziti/foundation/transport/tcp"
|
||||
|
||||
@@ -18,9 +18,9 @@ package network
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/db"
|
||||
"github.com/openziti/fabric/controller/models"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/common"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/openziti/foundation/util/concurrenz"
|
||||
|
||||
@@ -19,10 +19,10 @@ package network
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel/protobufs"
|
||||
"github.com/openziti/fabric/controller/xt"
|
||||
"github.com/openziti/fabric/logcontext"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
cmap "github.com/orcaman/concurrent-map"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -150,8 +150,8 @@ attendance:
|
||||
func (self *routeSender) sendRoute(r *Router, routeMsg *ctrl_pb.Route, ctx logcontext.Context) {
|
||||
logger := pfxlog.ChannelLogger(logcontext.EstablishPath).Wire(ctx).WithField("routerId", r.Id)
|
||||
|
||||
sendCtx := channel.MarshalTyped(routeMsg).WithTimeout(3 * time.Second)
|
||||
if err := sendCtx.SendAndWaitForWire(r.Control); err != nil {
|
||||
envelope := protobufs.MarshalTyped(routeMsg).WithTimeout(3 * time.Second)
|
||||
if err := envelope.SendAndWaitForWire(r.Control); err != nil {
|
||||
logger.WithError(err).Error("failure sending route message")
|
||||
} else {
|
||||
logger.Debug("sent route message")
|
||||
|
||||
@@ -3,9 +3,9 @@ package controller
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/network"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
)
|
||||
|
||||
// OnConnectSettingsHandler sends a ctrl_pb.ContentType_SettingsType message when routers connect if necessary
|
||||
|
||||
@@ -17,19 +17,21 @@
|
||||
package xctrl
|
||||
|
||||
import (
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/channel/protobufs"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Capabilities struct {
|
||||
channel2.Channel
|
||||
channel.Channel
|
||||
}
|
||||
|
||||
func (capabilities *Capabilities) Get(timeout time.Duration) ([]string, error) {
|
||||
request := &ctrl_pb.InspectRequest{RequestedValues: []string{"capability"}}
|
||||
response := &ctrl_pb.InspectResponse{}
|
||||
if err := capabilities.Channel.SendForReplyAndDecode(request, timeout, response); err != nil {
|
||||
respMsg, err := protobufs.MarshalTyped(request).WithTimeout(timeout).SendForReply(capabilities.Channel)
|
||||
if err = protobufs.TypedResponse(response).Unmarshall(respMsg, err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result []string
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package xctrl
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/config"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/xctrl"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/storage/boltz"
|
||||
"github.com/sirupsen/logrus"
|
||||
"time"
|
||||
@@ -58,8 +58,8 @@ func (example *example) Enabled() bool {
|
||||
return example.enabled
|
||||
}
|
||||
|
||||
func (example *example) BindChannel(ch channel.Channel) error {
|
||||
ch.AddReceiveHandler(newReceiveHandler())
|
||||
func (example *example) BindChannel(binding channel.Binding) error {
|
||||
binding.AddTypedReceiveHandler(newReceiveHandler())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type receiveHandler struct{}
|
||||
|
||||
func newReceiveHandler() channel.ReceiveHandler {
|
||||
func newReceiveHandler() channel.TypedReceiveHandler {
|
||||
return &receiveHandler{}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
package xmgmt
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/config"
|
||||
)
|
||||
|
||||
type Xmgmt interface {
|
||||
config.Subconfig
|
||||
channel2.BindHandler
|
||||
channel.BindHandler
|
||||
Enabled() bool
|
||||
Run(mgmt channel2.Channel, done chan struct{}) error
|
||||
Run(mgmt channel.Channel, done chan struct{}) error
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package ctrl_msg
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ func (event *JsonMetricsEvent) WriteTo(output io.WriteCloser) error {
|
||||
jsonRep["metric"] = event.Metric
|
||||
jsonRep["source_id"] = event.SourceAppId
|
||||
jsonRep["source_event_id"] = event.SourceEventId
|
||||
jsonRep["version"] = event.Version
|
||||
if event.SourceEntityId != "" {
|
||||
jsonRep["source_entity_id"] = event.SourceEntityId
|
||||
}
|
||||
|
||||
+45
-45
@@ -19,15 +19,9 @@ func init() {
|
||||
|
||||
func mapCtrlIds(_ *metrics_pb.MetricsMessage, event *MetricsEvent) {
|
||||
if strings.HasPrefix(event.Metric, "ctrl.") {
|
||||
if strings.HasSuffix(event.Metric, "latency") {
|
||||
name, routerId := ExtractId(event.Metric, "ctrl.", 1)
|
||||
event.Metric = name
|
||||
event.SourceEntityId = routerId
|
||||
} else {
|
||||
name, routerId := ExtractId(event.Metric, "ctrl.", 2)
|
||||
event.Metric = name
|
||||
event.SourceEntityId = routerId
|
||||
}
|
||||
parts := strings.Split(event.Metric, ":")
|
||||
event.Metric = parts[0]
|
||||
event.SourceEntityId = parts[1]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +126,7 @@ func (adapter *metricsAdapter) newMetricEvent(msg *metrics_pb.MetricsMessage, na
|
||||
Metric: name,
|
||||
Tags: msg.Tags,
|
||||
SourceEventId: id,
|
||||
Version: 2,
|
||||
}
|
||||
|
||||
for _, mapper := range metricsMappers {
|
||||
@@ -168,62 +163,66 @@ func (adapter *metricsAdapter) AcceptMetrics(msg *metrics_pb.MetricsMessage) {
|
||||
|
||||
for name, value := range msg.Meters {
|
||||
event := adapter.newMetricEvent(msg, name, parentEventId)
|
||||
adapter.filterMetric(".count", value.Count, event)
|
||||
adapter.filterMetric(".mean_rate", value.MeanRate, event)
|
||||
adapter.filterMetric(".m1_rate", value.M1Rate, event)
|
||||
adapter.filterMetric(".m5_rate", value.M5Rate, event)
|
||||
adapter.filterMetric(".m15_rate", value.M15Rate, event)
|
||||
adapter.filterMetric("count", value.Count, event)
|
||||
adapter.filterMetric("mean_rate", value.MeanRate, event)
|
||||
adapter.filterMetric("m1_rate", value.M1Rate, event)
|
||||
adapter.filterMetric("m5_rate", value.M5Rate, event)
|
||||
adapter.filterMetric("m15_rate", value.M15Rate, event)
|
||||
adapter.finishEvent(event)
|
||||
}
|
||||
|
||||
for name, value := range msg.Histograms {
|
||||
event := adapter.newMetricEvent(msg, name, parentEventId)
|
||||
adapter.filterMetric(".count", value.Count, event)
|
||||
adapter.filterMetric(".min", value.Min, event)
|
||||
adapter.filterMetric(".max", value.Max, event)
|
||||
adapter.filterMetric(".mean", value.Mean, event)
|
||||
adapter.filterMetric(".std_dev", value.StdDev, event)
|
||||
adapter.filterMetric(".variance", value.Variance, event)
|
||||
adapter.filterMetric(".p50", value.P50, event)
|
||||
adapter.filterMetric(".p75", value.P75, event)
|
||||
adapter.filterMetric(".p95", value.P95, event)
|
||||
adapter.filterMetric(".p99", value.P99, event)
|
||||
adapter.filterMetric(".p999", value.P999, event)
|
||||
adapter.filterMetric(".p9999", value.P9999, event)
|
||||
adapter.filterMetric("count", value.Count, event)
|
||||
adapter.filterMetric("min", value.Min, event)
|
||||
adapter.filterMetric("max", value.Max, event)
|
||||
adapter.filterMetric("mean", value.Mean, event)
|
||||
adapter.filterMetric("std_dev", value.StdDev, event)
|
||||
adapter.filterMetric("variance", value.Variance, event)
|
||||
adapter.filterMetric("p50", value.P50, event)
|
||||
adapter.filterMetric("p75", value.P75, event)
|
||||
adapter.filterMetric("p95", value.P95, event)
|
||||
adapter.filterMetric("p99", value.P99, event)
|
||||
adapter.filterMetric("p999", value.P999, event)
|
||||
adapter.filterMetric("p9999", value.P9999, event)
|
||||
adapter.finishEvent(event)
|
||||
}
|
||||
|
||||
for name, value := range msg.Timers {
|
||||
event := adapter.newMetricEvent(msg, name, parentEventId)
|
||||
adapter.filterMetric(".count", value.Count, event)
|
||||
adapter.filterMetric("count", value.Count, event)
|
||||
|
||||
adapter.filterMetric(".mean_rate", value.MeanRate, event)
|
||||
adapter.filterMetric(".m1_rate", value.M1Rate, event)
|
||||
adapter.filterMetric(".m5_rate", value.M5Rate, event)
|
||||
adapter.filterMetric(".m15_rate", value.M15Rate, event)
|
||||
adapter.filterMetric("mean_rate", value.MeanRate, event)
|
||||
adapter.filterMetric("m1_rate", value.M1Rate, event)
|
||||
adapter.filterMetric("m5_rate", value.M5Rate, event)
|
||||
adapter.filterMetric("m15_rate", value.M15Rate, event)
|
||||
|
||||
adapter.filterMetric(".min", value.Min, event)
|
||||
adapter.filterMetric(".max", value.Max, event)
|
||||
adapter.filterMetric(".mean", value.Mean, event)
|
||||
adapter.filterMetric(".std_dev", value.StdDev, event)
|
||||
adapter.filterMetric(".variance", value.Variance, event)
|
||||
adapter.filterMetric(".p50", value.P50, event)
|
||||
adapter.filterMetric(".p75", value.P75, event)
|
||||
adapter.filterMetric(".p95", value.P95, event)
|
||||
adapter.filterMetric(".p99", value.P99, event)
|
||||
adapter.filterMetric(".p999", value.P999, event)
|
||||
adapter.filterMetric(".p9999", value.P9999, event)
|
||||
adapter.filterMetric("min", value.Min, event)
|
||||
adapter.filterMetric("max", value.Max, event)
|
||||
adapter.filterMetric("mean", value.Mean, event)
|
||||
adapter.filterMetric("std_dev", value.StdDev, event)
|
||||
adapter.filterMetric("variance", value.Variance, event)
|
||||
adapter.filterMetric("p50", value.P50, event)
|
||||
adapter.filterMetric("p75", value.P75, event)
|
||||
adapter.filterMetric("p95", value.P95, event)
|
||||
adapter.filterMetric("p99", value.P99, event)
|
||||
adapter.filterMetric("p999", value.P999, event)
|
||||
adapter.filterMetric("p9999", value.P9999, event)
|
||||
adapter.finishEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
func (adapter *metricsAdapter) filterMetric(suffix string, value interface{}, event *MetricsEvent) {
|
||||
name := event.Metric + suffix
|
||||
func (adapter *metricsAdapter) filterMetric(key string, value interface{}, event *MetricsEvent) {
|
||||
name := event.Metric + key
|
||||
if adapter.nameMatches(name) {
|
||||
if event.Metrics == nil {
|
||||
event.Metrics = make(map[string]interface{})
|
||||
}
|
||||
event.Metrics[name] = value
|
||||
if key == "" {
|
||||
event.Metrics["value"] = value
|
||||
} else {
|
||||
event.Metrics[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +234,7 @@ type MetricsEvent struct {
|
||||
Namespace string
|
||||
SourceAppId string
|
||||
SourceEntityId string
|
||||
Version uint32
|
||||
Timestamp *timestamp.Timestamp
|
||||
Metric string
|
||||
Metrics map[string]interface{}
|
||||
|
||||
+14
-15
@@ -20,9 +20,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/ctrl_msg"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/metrics/metrics_pb"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -37,7 +36,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_CircuitRequestType):
|
||||
circuitRequest := &CircuitRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, circuitRequest); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Circuit Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Circuit Request")
|
||||
meta["ingressId"] = circuitRequest.IngressId
|
||||
meta["serviceId"] = circuitRequest.ServiceId
|
||||
headers := make([]string, 0)
|
||||
@@ -61,7 +60,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_CreateTerminatorRequestType):
|
||||
createTerminator := &CreateTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, createTerminator); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Create Terminator Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Create Terminator Request")
|
||||
meta["terminator"] = terminatorToString(createTerminator)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -80,7 +79,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_RemoveTerminatorRequestType):
|
||||
removeTerminator := &RemoveTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, removeTerminator); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Remove Terminator Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Remove Terminator Request")
|
||||
meta["terminatorId"] = removeTerminator.TerminatorId
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -99,7 +98,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_ValidateTerminatorsRequestType):
|
||||
request := &ValidateTerminatorsRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Validate Terminators")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Validate Terminators")
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
if err != nil {
|
||||
@@ -115,7 +114,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
}
|
||||
|
||||
case int32(ctrl_msg.CircuitSuccessType):
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Circuit Success Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Circuit Success Response")
|
||||
meta["circuitId"] = string(msg.Body)
|
||||
meta["address"] = string(msg.Headers[ctrl_msg.CircuitSuccessAddressHeader])
|
||||
|
||||
@@ -127,7 +126,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
return data, true
|
||||
|
||||
case int32(ctrl_msg.CircuitFailedType):
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Circuit Failed Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Circuit Failed Response")
|
||||
message := string(msg.Body)
|
||||
if message != "" {
|
||||
meta["message"] = message
|
||||
@@ -143,7 +142,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_DialType):
|
||||
connect := &Dial{}
|
||||
if err := proto.Unmarshal(msg.Body, connect); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Dial")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Dial")
|
||||
meta["linkId"] = connect.LinkId
|
||||
meta["address"] = connect.Address
|
||||
meta["routerId"] = connect.RouterId
|
||||
@@ -163,7 +162,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_LinkType):
|
||||
link := &Link{}
|
||||
if err := proto.Unmarshal(msg.Body, link); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Link")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Link")
|
||||
meta["id"] = link.Id
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -181,7 +180,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_FaultType):
|
||||
fault := &Fault{}
|
||||
if err := proto.Unmarshal(msg.Body, fault); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Fault")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Fault")
|
||||
meta["subject"] = fault.Subject.String()
|
||||
meta["id"] = fault.Id
|
||||
|
||||
@@ -200,7 +199,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_RouteType):
|
||||
route := &Route{}
|
||||
if err := proto.Unmarshal(msg.Body, route); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Route")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Route")
|
||||
meta["circuitId"] = route.CircuitId
|
||||
if route.Egress != nil {
|
||||
meta["egress.address"] = route.Egress.Address
|
||||
@@ -226,7 +225,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_UnrouteType):
|
||||
unroute := &Unroute{}
|
||||
if err := proto.Unmarshal(msg.Body, unroute); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Unroute")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Unroute")
|
||||
meta["circuitId"] = unroute.CircuitId
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -243,7 +242,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_MetricsType):
|
||||
metricsMsg := &metrics_pb.MetricsMessage{}
|
||||
if err := proto.Unmarshal(msg.Body, metricsMsg); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Metrics")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Metrics")
|
||||
|
||||
for name, metric := range metricsMsg.Histograms {
|
||||
meta[name+".min"] = metric.Min
|
||||
@@ -281,7 +280,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
}
|
||||
|
||||
case int32(ctrl_msg.RouteResultType):
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Route Result")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Route Result")
|
||||
meta["circuitId"] = string(msg.Body)
|
||||
meta["attempt"], _ = msg.GetUint32Header(ctrl_msg.RouteResultAttemptHeader)
|
||||
success, _ := msg.GetBoolHeader(ctrl_msg.RouteResultSuccessHeader)
|
||||
|
||||
+24
-25
@@ -20,8 +20,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/channel"
|
||||
)
|
||||
|
||||
type Decoder struct{}
|
||||
@@ -31,7 +30,7 @@ const DECODER = "mgmt"
|
||||
func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
switch msg.ContentType {
|
||||
case int32(ContentType_ListServicesRequestType):
|
||||
data, err := channel2.NewTraceMessageDecode(DECODER, "List Services Request").MarshalTraceMessageDecode()
|
||||
data, err := channel.NewTraceMessageDecode(DECODER, "List Services Request").MarshalTraceMessageDecode()
|
||||
if err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error (%s)", err)
|
||||
return nil, true
|
||||
@@ -42,7 +41,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_ListServicesResponseType):
|
||||
listServices := &ListServicesResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, listServices); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "List Services Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "List Services Response")
|
||||
meta["services"] = len(listServices.Services)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -61,7 +60,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_CreateServiceRequestType):
|
||||
createService := &CreateServiceRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, createService); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Create Service Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Create Service Request")
|
||||
meta["service"] = serviceToString(createService.Service)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -80,7 +79,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_RemoveServiceRequestType):
|
||||
removeService := &RemoveServiceRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, removeService); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Remove Service Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Remove Service Request")
|
||||
meta["serviceId"] = removeService.ServiceId
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -99,7 +98,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_GetServiceRequestType):
|
||||
getService := &GetServiceRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, getService); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Get Service Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Get Service Request")
|
||||
meta["serviceId"] = getService.ServiceId
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -118,7 +117,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_GetServiceResponseType):
|
||||
getService := &GetServiceResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, getService); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Get Service Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Get Service Response")
|
||||
meta["service"] = serviceToString(getService.Service)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -136,7 +135,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
|
||||
// terminator messages
|
||||
case int32(ContentType_ListTerminatorsRequestType):
|
||||
data, err := channel2.NewTraceMessageDecode(DECODER, "List Terminators Request").MarshalTraceMessageDecode()
|
||||
data, err := channel.NewTraceMessageDecode(DECODER, "List Terminators Request").MarshalTraceMessageDecode()
|
||||
if err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error (%s)", err)
|
||||
return nil, true
|
||||
@@ -147,7 +146,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_ListTerminatorsResponseType):
|
||||
listTerminators := &ListTerminatorsResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, listTerminators); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "List Terminators Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "List Terminators Response")
|
||||
meta["terminators"] = len(listTerminators.Terminators)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -166,7 +165,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_CreateTerminatorRequestType):
|
||||
createTerminator := &CreateTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, createTerminator); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Create Terminator Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Create Terminator Request")
|
||||
meta["terminator"] = terminatorToString(createTerminator.Terminator)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -185,7 +184,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_RemoveTerminatorRequestType):
|
||||
removeTerminator := &RemoveTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, removeTerminator); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Remove Terminator Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Remove Terminator Request")
|
||||
meta["terminatorId"] = removeTerminator.TerminatorId
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -204,7 +203,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_GetTerminatorRequestType):
|
||||
getTerminator := &GetTerminatorRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, getTerminator); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Get Terminator Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Get Terminator Request")
|
||||
meta["terminatorId"] = getTerminator.TerminatorId
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -223,7 +222,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_GetTerminatorResponseType):
|
||||
getTerminator := &GetTerminatorResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, getTerminator); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Get Terminator Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Get Terminator Response")
|
||||
meta["terminator"] = terminatorToString(getTerminator.Terminator)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -242,7 +241,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_SetTerminatorCostRequestType):
|
||||
request := &SetTerminatorCostRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, request); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Set Terminator Weight Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Set Terminator Weight Request")
|
||||
meta["terminatorId"] = request.TerminatorId
|
||||
meta["staticCost"] = request.StaticCost
|
||||
meta["precedence"] = request.Precedence.String()
|
||||
@@ -263,7 +262,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
}
|
||||
// router messages
|
||||
case int32(ContentType_ListRoutersRequestType):
|
||||
data, err := channel2.NewTraceMessageDecode(DECODER, "List Routers Request").MarshalTraceMessageDecode()
|
||||
data, err := channel.NewTraceMessageDecode(DECODER, "List Routers Request").MarshalTraceMessageDecode()
|
||||
if err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error (%s)", err)
|
||||
return nil, true
|
||||
@@ -274,7 +273,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_ListRoutersResponseType):
|
||||
listRouters := &ListRoutersResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, listRouters); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "List Routers Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "List Routers Response")
|
||||
meta["routers"] = len(listRouters.Routers)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -293,7 +292,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_CreateRouterRequestType):
|
||||
createRouter := &CreateRouterRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, createRouter); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Create Router Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Create Router Request")
|
||||
meta["router"] = routerToString(createRouter.Router)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -312,7 +311,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_RemoveRouterRequestType):
|
||||
removeRouter := &RemoveRouterRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, removeRouter); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Remove Router Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Remove Router Request")
|
||||
meta["routerId"] = removeRouter.RouterId
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -329,7 +328,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
}
|
||||
|
||||
case int32(ContentType_ListLinksRequestType):
|
||||
data, err := channel2.NewTraceMessageDecode(DECODER, "List Links Request").MarshalTraceMessageDecode()
|
||||
data, err := channel.NewTraceMessageDecode(DECODER, "List Links Request").MarshalTraceMessageDecode()
|
||||
if err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error (%s)", err)
|
||||
return nil, true
|
||||
@@ -340,7 +339,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_ListLinksResponseType):
|
||||
listLinks := &ListLinksResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, listLinks); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "List Links Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "List Links Response")
|
||||
meta["links"] = len(listLinks.Links)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
@@ -359,7 +358,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_SetLinkCostRequestType):
|
||||
setLinkCost := &SetLinkCostRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, setLinkCost); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Set Link Cost Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Set Link Cost Request")
|
||||
meta["linkId"] = setLinkCost.LinkId
|
||||
meta["cost"] = setLinkCost.Cost
|
||||
|
||||
@@ -379,7 +378,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_SetLinkDownRequestType):
|
||||
setLinkDown := &SetLinkDownRequest{}
|
||||
if err := proto.Unmarshal(msg.Body, setLinkDown); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "Set Link Down Request")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "Set Link Down Request")
|
||||
meta["linkId"] = setLinkDown.LinkId
|
||||
meta["down"] = setLinkDown.Down
|
||||
|
||||
@@ -397,7 +396,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
}
|
||||
|
||||
case int32(ContentType_ListCircuitsRequestType):
|
||||
data, err := channel2.NewTraceMessageDecode(DECODER, "List Circuits Request").MarshalTraceMessageDecode()
|
||||
data, err := channel.NewTraceMessageDecode(DECODER, "List Circuits Request").MarshalTraceMessageDecode()
|
||||
if err != nil {
|
||||
pfxlog.Logger().Errorf("unexpected error (%s)", err)
|
||||
return nil, true
|
||||
@@ -408,7 +407,7 @@ func (d Decoder) Decode(msg *channel.Message) ([]byte, bool) {
|
||||
case int32(ContentType_ListCircuitsResponseType):
|
||||
listCircuits := &ListCircuitsResponse{}
|
||||
if err := proto.Unmarshal(msg.Body, listCircuits); err == nil {
|
||||
meta := channel2.NewTraceMessageDecode(DECODER, "List Circuits Response")
|
||||
meta := channel.NewTraceMessageDecode(DECODER, "List Circuits Response")
|
||||
meta["circuits"] = len(listCircuits.Circuits)
|
||||
|
||||
data, err := meta.MarshalTraceMessageDecode()
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/metrics"
|
||||
)
|
||||
|
||||
// NewCtrlChannelPeekHandler creates a channel PeekHandler which tracks message rate and message size distribution
|
||||
func NewCtrlChannelPeekHandler(routerId string, registry metrics.Registry) channel.PeekHandler {
|
||||
txBytesMeter := registry.Meter("ctrl." + routerId + ".tx.bytesrate")
|
||||
txMsgMeter := registry.Meter("ctrl." + routerId + ".tx.msgrate")
|
||||
txMsgSizeHistogram := registry.Histogram("ctrl." + routerId + ".tx.msgsize")
|
||||
rxBytesMeter := registry.Meter("ctrl." + routerId + ".rx.bytesrate")
|
||||
rxMsgMeter := registry.Meter("ctrl." + routerId + ".rx.msgrate")
|
||||
rxMsgSizeHistogram := registry.Histogram("ctrl." + routerId + ".rx.msgsize")
|
||||
txBytesMeter := registry.Meter("ctrl.tx.bytesrate:" + routerId)
|
||||
txMsgMeter := registry.Meter("ctrl.tx.msgrate:" + routerId)
|
||||
txMsgSizeHistogram := registry.Histogram("ctrl.tx.msgsize:" + routerId)
|
||||
rxBytesMeter := registry.Meter("ctrl.rx.bytesrate:" + routerId)
|
||||
rxMsgMeter := registry.Meter("ctrl.rx.msgrate:" + routerId)
|
||||
rxMsgSizeHistogram := registry.Histogram("ctrl.rx.msgsize:" + routerId)
|
||||
|
||||
closeHook := func() {
|
||||
txBytesMeter.Dispose()
|
||||
|
||||
+1
-1
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/AppsFlyer/go-sundheit/checks"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/controller/xctrl"
|
||||
"github.com/openziti/fabric/event"
|
||||
"github.com/openziti/fabric/health"
|
||||
@@ -43,7 +44,6 @@ import (
|
||||
"github.com/openziti/fabric/router/xlink"
|
||||
"github.com/openziti/fabric/router/xlink_transport"
|
||||
"github.com/openziti/fabric/xweb"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/common"
|
||||
"github.com/openziti/foundation/metrics"
|
||||
|
||||
@@ -19,7 +19,7 @@ package xgress
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package xgress
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"github.com/openziti/foundation/channel"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/foundation/util/info"
|
||||
"github.com/openziti/foundation/util/uuidz"
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"github.com/openziti/foundation/channel2"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
"github.com/openziti/foundation/transport"
|
||||
"testing"
|
||||
@@ -22,8 +22,8 @@ func Test_MgmtChannelInvalidClient(t *testing.T) {
|
||||
ctx.Req.NoError(err)
|
||||
mgmtAddress, err := transport.ParseAddress("tls:localhost:10001")
|
||||
ctx.Req.NoError(err)
|
||||
dialer := channel2.NewClassicDialer(badId, mgmtAddress, nil)
|
||||
_, err = channel2.NewChannel("mgmt", dialer, nil)
|
||||
dialer := channel.NewClassicDialer(badId, mgmtAddress, nil)
|
||||
_, err = channel.NewChannel("mgmt", dialer, nil)
|
||||
ctx.Req.Error(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/channel"
|
||||
"github.com/openziti/fabric/pb/ctrl_pb"
|
||||
"github.com/openziti/fabric/pb/mgmt_pb"
|
||||
"github.com/openziti/fabric/router/xgress"
|
||||
"github.com/openziti/foundation/channel"
|
||||
trace_pb "github.com/openziti/foundation/trace/pb"
|
||||
"github.com/openziti/foundation/util/concurrenz"
|
||||
"time"
|
||||
|
||||
Reference in New Issue
Block a user