refact(api): move worker handlers
This commit is contained in:
1 parent
3e314a45f9
commit
c811dff89b
8 files changed
+21
-21
No files matched your search
@@ -13,7 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/workers"
|
||||
"github.com/hashicorp/boundary/internal/daemon/cluster/handlers"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
@@ -136,11 +136,11 @@ func (w *Worker) configureForWorker(ln *base.ServerListener, logger *log.Logger)
|
||||
grpc.MaxRecvMsgSize(math.MaxInt32),
|
||||
grpc.MaxSendMsgSize(math.MaxInt32),
|
||||
)
|
||||
multihopService := workers.NewMultihopServiceServer(
|
||||
multihopService := handlers.NewMultihopServiceServer(
|
||||
nodeauth.MakeCurrentParametersFactory(w.baseContext, nodee.NopTransactionStorage(w.NodeeFileStorage)),
|
||||
)
|
||||
multihop.RegisterMultihopServiceServer(downstreamServer, multihopService)
|
||||
statusSessionService := workers.NewWorkerProxyServiceServer(w.controllerStatusConn, w.controllerSessionConn)
|
||||
statusSessionService := NewWorkerProxyServiceServer(w.controllerStatusConn, w.controllerSessionConn)
|
||||
pbs.RegisterServerCoordinationServiceServer(downstreamServer, statusSessionService)
|
||||
pbs.RegisterSessionServiceServer(downstreamServer, statusSessionService)
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package worker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
)
|
||||
|
||||
type workerProxyServiceServer struct {
|
||||
pbs.UnimplementedServerCoordinationServiceServer
|
||||
pbs.UnimplementedSessionServiceServer
|
||||
|
||||
scsClient *atomic.Value
|
||||
ssClient *atomic.Value
|
||||
}
|
||||
|
||||
func NewWorkerProxyServiceServer(
|
||||
scsClient *atomic.Value,
|
||||
ssClient *atomic.Value,
|
||||
) *workerProxyServiceServer {
|
||||
return &workerProxyServiceServer{
|
||||
scsClient: scsClient,
|
||||
ssClient: ssClient,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
_ pbs.ServerCoordinationServiceServer = &workerProxyServiceServer{}
|
||||
_ pbs.SessionServiceServer = &workerProxyServiceServer{}
|
||||
)
|
||||
|
||||
func (ws *workerProxyServiceServer) Status(ctx context.Context, req *pbs.StatusRequest) (*pbs.StatusResponse, error) {
|
||||
return ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).Status(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) LookupSession(ctx context.Context, req *pbs.LookupSessionRequest) (*pbs.LookupSessionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).LookupSession(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) CancelSession(ctx context.Context, req *pbs.CancelSessionRequest) (*pbs.CancelSessionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).CancelSession(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) ActivateSession(ctx context.Context, req *pbs.ActivateSessionRequest) (*pbs.ActivateSessionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).ActivateSession(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) AuthorizeConnection(ctx context.Context, req *pbs.AuthorizeConnectionRequest) (*pbs.AuthorizeConnectionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).AuthorizeConnection(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) ConnectConnection(ctx context.Context, req *pbs.ConnectConnectionRequest) (*pbs.ConnectConnectionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).ConnectConnection(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) CloseConnection(ctx context.Context, req *pbs.CloseConnectionRequest) (*pbs.CloseConnectionResponse, error) {
|
||||
return ws.ssClient.Load().(pbs.SessionServiceClient).CloseConnection(ctx, req)
|
||||
}
|
||||
Reference in new issue
Block a user