mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-09 23:19:11 +02:00
Merge remote-tracking branch 'origin/main' into jnfrati/ubi-signal
This commit is contained in:
@@ -119,6 +119,7 @@ var (
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating signal server: %v", err)
|
||||
}
|
||||
defer srv.Stop()
|
||||
proto.RegisterSignalExchangeServer(grpcServer, srv)
|
||||
|
||||
grpcRootHandler := grpcHandlerFunc(grpcServer, metricsServer.Meter)
|
||||
|
||||
@@ -17,6 +17,8 @@ import (
|
||||
|
||||
"github.com/netbirdio/signal-dispatcher/dispatcher"
|
||||
|
||||
"github.com/netbirdio/netbird/shared/lifecycle"
|
||||
"github.com/netbirdio/netbird/shared/profiling"
|
||||
"github.com/netbirdio/netbird/shared/signal/proto"
|
||||
"github.com/netbirdio/netbird/signal/metrics"
|
||||
"github.com/netbirdio/netbird/signal/peer"
|
||||
@@ -43,6 +45,8 @@ const (
|
||||
labelRegistrationNotFound = "not_found"
|
||||
|
||||
sendTimeout = 10 * time.Second
|
||||
|
||||
applicationName = "signal"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -51,6 +55,7 @@ var (
|
||||
|
||||
// Server an instance of a Signal server
|
||||
type Server struct {
|
||||
lifecycle.StopHandlers
|
||||
registry *peer.Registry
|
||||
proto.UnimplementedSignalExchangeServer
|
||||
dispatcher *dispatcher.Dispatcher
|
||||
@@ -88,9 +93,17 @@ func NewServer(ctx context.Context, meter metric.Meter, metricsPrefix ...string)
|
||||
sendTimeout: sTimeout,
|
||||
}
|
||||
|
||||
stopProfiling := profiling.Start(applicationName)
|
||||
s.OnStop(stopProfiling)
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// Stop runs the handlers registered with OnStop.
|
||||
func (s *Server) Stop() {
|
||||
s.RunStopHandlers()
|
||||
}
|
||||
|
||||
// Send forwards a message to the signal peer
|
||||
func (s *Server) Send(ctx context.Context, msg *proto.EncryptedMessage) (*proto.EncryptedMessage, error) {
|
||||
log.Tracef("received a new message to send from peer [%s] to peer [%s]", msg.Key, msg.RemoteKey)
|
||||
|
||||
Reference in New Issue
Block a user