Fix error about unimplemented HcpbWorkers call (#2361)
Although there is a compile time check on the type, it will always succeed due to the Unimplemented embedding requirement. As a result, this PR also changes Unimplemented calls to Unsafe calls, which were added later "for those that prefer their code to break"; the comments on these state: // UnsafeXServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to XServiceServer will // result in compilation errors. See https://github.com/grpc/grpc-go/issues/4500#issuecomment-852597871 for some more context. I think we're fine with compilation errors though; we own both the server and client side of things and generally are going to add new methods only when we intend to also add them on the client side. Notably, what the comment does not indicate is that it will break at runtime; already it should return a suitable (404 or 405) error if the client requests a method that does not exist.
This commit is contained in:
1 parent
17ddc301a8
commit
9b271d7dd8
21 files changed
+72
-66
No files matched your search
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
type multihopServiceServer struct {
|
||||
multihop.UnimplementedMultihopServiceServer
|
||||
multihop.UnsafeMultihopServiceServer
|
||||
|
||||
storage nodeenrollment.Storage
|
||||
direct bool
|
||||
@@ -24,6 +24,8 @@ type multihopServiceServer struct {
|
||||
options []nodeenrollment.Option
|
||||
}
|
||||
|
||||
var _ multihop.MultihopServiceServer = (*multihopServiceServer)(nil)
|
||||
|
||||
// NewMultihopServiceServer creates a new service implementing
|
||||
// MultihopServiceServer, storing values used for the implementing functions.
|
||||
func NewMultihopServiceServer(storage nodeenrollment.Storage, direct bool, client *atomic.Value, opt ...nodeenrollment.Option) (*multihopServiceServer, error) {
|
||||
@@ -44,8 +46,6 @@ func NewMultihopServiceServer(storage nodeenrollment.Storage, direct bool, clien
|
||||
}, nil
|
||||
}
|
||||
|
||||
var _ multihop.MultihopServiceServer = (*multihopServiceServer)(nil)
|
||||
|
||||
// FetchNodeCredentials implements the MultihopServiceServer interface. If it's
|
||||
// direct (e.g. running on a controller) it handles the request directly,
|
||||
// otherwise sends it to its next hop.
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
const ManagedWorkerTagKey = "boundary.cloud.hashicorp.com:managed"
|
||||
|
||||
type workerServiceServer struct {
|
||||
pbs.UnimplementedServerCoordinationServiceServer
|
||||
pbs.UnimplementedSessionServiceServer
|
||||
pbs.UnsafeServerCoordinationServiceServer
|
||||
pbs.UnsafeSessionServiceServer
|
||||
|
||||
serversRepoFn common.ServersRepoFactory
|
||||
sessionRepoFn common.SessionRepoFactory
|
||||
@@ -35,6 +35,11 @@ type workerServiceServer struct {
|
||||
kms *kms.Kms
|
||||
}
|
||||
|
||||
var (
|
||||
_ pbs.SessionServiceServer = &workerServiceServer{}
|
||||
_ pbs.ServerCoordinationServiceServer = &workerServiceServer{}
|
||||
)
|
||||
|
||||
func NewWorkerServiceServer(
|
||||
serversRepoFn common.ServersRepoFactory,
|
||||
sessionRepoFn common.SessionRepoFactory,
|
||||
@@ -51,11 +56,6 @@ func NewWorkerServiceServer(
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
_ pbs.SessionServiceServer = &workerServiceServer{}
|
||||
_ pbs.ServerCoordinationServiceServer = &workerServiceServer{}
|
||||
)
|
||||
|
||||
func (ws *workerServiceServer) Status(ctx context.Context, req *pbs.StatusRequest) (*pbs.StatusResponse, error) {
|
||||
const op = "workers.(workerServiceServer).Status"
|
||||
// TODO: on the worker, if we get errors back from this repeatedly, do we
|
||||
|
||||
@@ -96,12 +96,14 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.AccountServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedAccountServiceServer
|
||||
pbs.UnsafeAccountServiceServer
|
||||
|
||||
pwRepoFn common.PasswordAuthRepoFactory
|
||||
oidcRepoFn common.OidcAuthRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.AccountServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a account service which handles account related requests to boundary.
|
||||
func NewService(pwRepo common.PasswordAuthRepoFactory, oidcRepo common.OidcAuthRepoFactory) (Service, error) {
|
||||
const op = "accounts.NewService"
|
||||
@@ -114,8 +116,6 @@ func NewService(pwRepo common.PasswordAuthRepoFactory, oidcRepo common.OidcAuthR
|
||||
return Service{pwRepoFn: pwRepo, oidcRepoFn: oidcRepo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.AccountServiceServer = Service{}
|
||||
|
||||
// ListAccounts implements the interface pbs.AccountServiceServer.
|
||||
func (s Service) ListAccounts(ctx context.Context, req *pbs.ListAccountsRequest) (*pbs.ListAccountsResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -76,7 +76,7 @@ var (
|
||||
|
||||
// Service handles request as described by the pbs.AuthMethodServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedAuthMethodServiceServer
|
||||
pbs.UnsafeAuthMethodServiceServer
|
||||
|
||||
kms *kms.Kms
|
||||
pwRepoFn common.PasswordAuthRepoFactory
|
||||
@@ -85,6 +85,8 @@ type Service struct {
|
||||
atRepoFn common.AuthTokenRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.AuthMethodServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a auth method service which handles auth method related requests to boundary.
|
||||
func NewService(kms *kms.Kms, pwRepoFn common.PasswordAuthRepoFactory, oidcRepoFn common.OidcAuthRepoFactory, iamRepoFn common.IamRepoFactory, atRepoFn common.AuthTokenRepoFactory, opt ...handlers.Option) (Service, error) {
|
||||
const op = "authmethods.NewService"
|
||||
@@ -108,8 +110,6 @@ func NewService(kms *kms.Kms, pwRepoFn common.PasswordAuthRepoFactory, oidcRepoF
|
||||
return s, nil
|
||||
}
|
||||
|
||||
var _ pbs.AuthMethodServiceServer = Service{}
|
||||
|
||||
// ListAuthMethods implements the interface pbs.AuthMethodServiceServer.
|
||||
func (s Service) ListAuthMethods(ctx context.Context, req *pbs.ListAuthMethodsRequest) (*pbs.ListAuthMethodsResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -41,12 +41,14 @@ var (
|
||||
|
||||
// Service handles request as described by the pbs.AuthTokenServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedAuthTokenServiceServer
|
||||
pbs.UnsafeAuthTokenServiceServer
|
||||
|
||||
repoFn common.AuthTokenRepoFactory
|
||||
iamRepoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.AuthTokenServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a user service which handles user related requests to boundary.
|
||||
func NewService(repo common.AuthTokenRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) {
|
||||
const op = "authtoken.NewService"
|
||||
@@ -59,8 +61,6 @@ func NewService(repo common.AuthTokenRepoFactory, iamRepoFn common.IamRepoFactor
|
||||
return Service{repoFn: repo, iamRepoFn: iamRepoFn}, nil
|
||||
}
|
||||
|
||||
var _ pbs.AuthTokenServiceServer = Service{}
|
||||
|
||||
// ListAuthTokens implements the interface pbs.AuthTokenServiceServer.
|
||||
func (s Service) ListAuthTokens(ctx context.Context, req *pbs.ListAuthTokensRequest) (*pbs.ListAuthTokensResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
+3
-3
@@ -74,12 +74,14 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.CredentialLibraryServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedCredentialLibraryServiceServer
|
||||
pbs.UnsafeCredentialLibraryServiceServer
|
||||
|
||||
iamRepoFn common.IamRepoFactory
|
||||
repoFn common.VaultCredentialRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.CredentialLibraryServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a credential library service which handles credential library related requests to boundary.
|
||||
func NewService(repo common.VaultCredentialRepoFactory, iamRepo common.IamRepoFactory) (Service, error) {
|
||||
const op = "credentiallibraries.NewService"
|
||||
@@ -92,8 +94,6 @@ func NewService(repo common.VaultCredentialRepoFactory, iamRepo common.IamRepoFa
|
||||
return Service{iamRepoFn: iamRepo, repoFn: repo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.CredentialLibraryServiceServer = Service{}
|
||||
|
||||
// ListCredentialLibraries implements the interface pbs.CredentialLibraryServiceServer
|
||||
func (s Service) ListCredentialLibraries(ctx context.Context, req *pbs.ListCredentialLibrariesRequest) (*pbs.ListCredentialLibrariesResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -70,12 +70,14 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.CredentialServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedCredentialServiceServer
|
||||
pbs.UnsafeCredentialServiceServer
|
||||
|
||||
iamRepoFn common.IamRepoFactory
|
||||
repoFn common.StaticCredentialRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.CredentialServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a credential service which handles credential related requests to boundary.
|
||||
func NewService(repo common.StaticCredentialRepoFactory, iamRepo common.IamRepoFactory) (Service, error) {
|
||||
const op = "credentials.NewService"
|
||||
@@ -88,8 +90,6 @@ func NewService(repo common.StaticCredentialRepoFactory, iamRepo common.IamRepoF
|
||||
return Service{iamRepoFn: iamRepo, repoFn: repo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.CredentialServiceServer = Service{}
|
||||
|
||||
// ListCredentials implements the interface pbs.CredentialServiceServer
|
||||
func (s Service) ListCredentials(ctx context.Context, req *pbs.ListCredentialsRequest) (*pbs.ListCredentialsResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -85,13 +85,15 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.CredentialStoreServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedCredentialStoreServiceServer
|
||||
pbs.UnsafeCredentialStoreServiceServer
|
||||
|
||||
iamRepoFn common.IamRepoFactory
|
||||
vaultRepoFn common.VaultCredentialRepoFactory
|
||||
staticRepoFn common.StaticCredentialRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.CredentialStoreServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a credential store service which handles credential store related requests to boundary.
|
||||
func NewService(
|
||||
ctx context.Context,
|
||||
@@ -112,8 +114,6 @@ func NewService(
|
||||
return Service{iamRepoFn: iamRepo, vaultRepoFn: vaultRepo, staticRepoFn: staticRepo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.CredentialStoreServiceServer = Service{}
|
||||
|
||||
// ListCredentialStores implements the interface pbs.CredentialStoreServiceServer
|
||||
func (s Service) ListCredentialStores(ctx context.Context, req *pbs.ListCredentialStoresRequest) (*pbs.ListCredentialStoresResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -56,11 +56,13 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.GroupServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedGroupServiceServer
|
||||
pbs.UnsafeGroupServiceServer
|
||||
|
||||
repoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.GroupServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a group service which handles group related requests to boundary.
|
||||
func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
const op = "groups.NewService"
|
||||
@@ -70,8 +72,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
return Service{repoFn: repo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.GroupServiceServer = Service{}
|
||||
|
||||
// ListGroups implements the interface pbs.GroupServiceServer.
|
||||
func (s Service) ListGroups(ctx context.Context, req *pbs.ListGroupsRequest) (*pbs.ListGroupsResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -9,11 +9,13 @@ import (
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
pbs.UnimplementedHealthServiceServer
|
||||
pbs.UnsafeHealthServiceServer
|
||||
|
||||
replyWithServiceUnavailable bool
|
||||
}
|
||||
|
||||
var _ pbs.HealthServiceServer = (*Service)(nil)
|
||||
|
||||
func NewService() *Service {
|
||||
s := Service{}
|
||||
return &s
|
||||
|
||||
@@ -81,7 +81,7 @@ func init() {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
pbs.UnimplementedHostCatalogServiceServer
|
||||
pbs.UnsafeHostCatalogServiceServer
|
||||
|
||||
staticRepoFn common.StaticRepoFactory
|
||||
pluginHostRepoFn common.PluginHostRepoFactory
|
||||
@@ -89,7 +89,7 @@ type Service struct {
|
||||
iamRepoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.HostCatalogServiceServer = Service{}
|
||||
var _ pbs.HostCatalogServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a host catalog Service which handles host catalog related requests to boundary and uses the provided
|
||||
// repositories for storage and retrieval.
|
||||
|
||||
@@ -75,13 +75,13 @@ func init() {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
pbs.UnimplementedHostSetServiceServer
|
||||
pbs.UnsafeHostSetServiceServer
|
||||
|
||||
staticRepoFn common.StaticRepoFactory
|
||||
pluginRepoFn common.PluginHostRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.HostSetServiceServer = Service{}
|
||||
var _ pbs.HostSetServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a host set Service which handles host set related requests to boundary and uses the provided
|
||||
// repositories for storage and retrieval.
|
||||
|
||||
@@ -64,13 +64,13 @@ func init() {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
pbs.UnimplementedHostServiceServer
|
||||
pbs.UnsafeHostServiceServer
|
||||
|
||||
staticRepoFn common.StaticRepoFactory
|
||||
pluginRepoFn common.PluginHostRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.HostServiceServer = Service{}
|
||||
var _ pbs.HostServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a host Service which handles host related requests to boundary and uses the provided
|
||||
// repositories for storage and retrieval.
|
||||
|
||||
@@ -63,11 +63,13 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.ManagedGroupServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedManagedGroupServiceServer
|
||||
pbs.UnsafeManagedGroupServiceServer
|
||||
|
||||
oidcRepoFn common.OidcAuthRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.ManagedGroupServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a managed group service which handles managed group related requests to boundary.
|
||||
func NewService(oidcRepo common.OidcAuthRepoFactory) (Service, error) {
|
||||
const op = "managed_groups.NewService"
|
||||
@@ -77,8 +79,6 @@ func NewService(oidcRepo common.OidcAuthRepoFactory) (Service, error) {
|
||||
return Service{oidcRepoFn: oidcRepo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.ManagedGroupServiceServer = Service{}
|
||||
|
||||
// ListManagedGroups implements the interface pbs.ManagedGroupsServiceServer.
|
||||
func (s Service) ListManagedGroups(ctx context.Context, req *pbs.ListManagedGroupsRequest) (*pbs.ListManagedGroupsResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -60,11 +60,13 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.RoleServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedRoleServiceServer
|
||||
pbs.UnsafeRoleServiceServer
|
||||
|
||||
repoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.RoleServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a role service which handles role related requests to boundary.
|
||||
func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
const op = "roles.NewService"
|
||||
@@ -74,8 +76,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
return Service{repoFn: repo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.RoleServiceServer = Service{}
|
||||
|
||||
// ListRoles implements the interface pbs.RoleServiceServer.
|
||||
func (s Service) ListRoles(ctx context.Context, req *pbs.ListRolesRequest) (*pbs.ListRolesResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -96,11 +96,13 @@ func init() {
|
||||
|
||||
// Service handles requests as described by the pbs.ScopeServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedScopeServiceServer
|
||||
pbs.UnsafeScopeServiceServer
|
||||
|
||||
repoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.ScopeServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a project service which handles project related requests to boundary.
|
||||
func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
const op = "scopes.(Service).NewService"
|
||||
@@ -110,8 +112,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
return Service{repoFn: repo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.ScopeServiceServer = Service{}
|
||||
|
||||
// ListScopes implements the interface pbs.ScopeServiceServer.
|
||||
func (s Service) ListScopes(ctx context.Context, req *pbs.ListScopesRequest) (*pbs.ListScopesResponse, error) {
|
||||
if req.GetScopeId() == "" {
|
||||
|
||||
@@ -43,12 +43,14 @@ var (
|
||||
|
||||
// Service handles request as described by the pbs.SessionServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedSessionServiceServer
|
||||
pbs.UnsafeSessionServiceServer
|
||||
|
||||
repoFn common.SessionRepoFactory
|
||||
iamRepoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.SessionServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a session service which handles session related requests to boundary.
|
||||
func NewService(repoFn common.SessionRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) {
|
||||
const op = "sessions.NewService"
|
||||
@@ -61,8 +63,6 @@ func NewService(repoFn common.SessionRepoFactory, iamRepoFn common.IamRepoFactor
|
||||
return Service{repoFn: repoFn, iamRepoFn: iamRepoFn}, nil
|
||||
}
|
||||
|
||||
var _ pbs.SessionServiceServer = Service{}
|
||||
|
||||
// GetSessions implements the interface pbs.SessionServiceServer.
|
||||
func (s Service) GetSession(ctx context.Context, req *pbs.GetSessionRequest) (*pbs.GetSessionResponse, error) {
|
||||
const op = "sessions.(Service).GetSession"
|
||||
|
||||
@@ -96,7 +96,7 @@ var (
|
||||
|
||||
// Service handles request as described by the pbs.TargetServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedTargetServiceServer
|
||||
pbs.UnsafeTargetServiceServer
|
||||
|
||||
repoFn common.TargetRepoFactory
|
||||
iamRepoFn common.IamRepoFactory
|
||||
@@ -109,6 +109,8 @@ type Service struct {
|
||||
kmsCache *kms.Kms
|
||||
}
|
||||
|
||||
var _ pbs.TargetServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a target service which handles target related requests to boundary.
|
||||
func NewService(
|
||||
ctx context.Context,
|
||||
@@ -160,8 +162,6 @@ func NewService(
|
||||
}, nil
|
||||
}
|
||||
|
||||
var _ pbs.TargetServiceServer = Service{}
|
||||
|
||||
// ListTargets implements the interface pbs.TargetServiceServer.
|
||||
func (s Service) ListTargets(ctx context.Context, req *pbs.ListTargetsRequest) (*pbs.ListTargetsResponse, error) {
|
||||
const op = "targets.(Service).ListSessions"
|
||||
|
||||
@@ -58,11 +58,13 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.UserServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedUserServiceServer
|
||||
pbs.UnsafeUserServiceServer
|
||||
|
||||
repoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.UserServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a user service which handles user related requests to boundary.
|
||||
func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
const op = "users.NewService"
|
||||
@@ -72,8 +74,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) {
|
||||
return Service{repoFn: repo}, nil
|
||||
}
|
||||
|
||||
var _ pbs.UserServiceServer = Service{}
|
||||
|
||||
// ListUsers implements the interface pbs.UserServiceServer.
|
||||
func (s Service) ListUsers(ctx context.Context, req *pbs.ListUsersRequest) (*pbs.ListUsersResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -66,12 +66,14 @@ func init() {
|
||||
|
||||
// Service handles request as described by the pbs.WorkerServiceServer interface.
|
||||
type Service struct {
|
||||
pbs.UnimplementedWorkerServiceServer
|
||||
pbs.UnsafeWorkerServiceServer
|
||||
|
||||
repoFn common.ServersRepoFactory
|
||||
iamRepoFn common.IamRepoFactory
|
||||
}
|
||||
|
||||
var _ pbs.WorkerServiceServer = (*Service)(nil)
|
||||
|
||||
// NewService returns a worker service which handles worker related requests to boundary.
|
||||
func NewService(ctx context.Context, repo common.ServersRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) {
|
||||
const op = "workers.NewService"
|
||||
@@ -84,8 +86,6 @@ func NewService(ctx context.Context, repo common.ServersRepoFactory, iamRepoFn c
|
||||
return Service{repoFn: repo, iamRepoFn: iamRepoFn}, nil
|
||||
}
|
||||
|
||||
var _ pbs.WorkerServiceServer = Service{}
|
||||
|
||||
// ListWorkers implements the interface pbs.WorkerServiceServer.
|
||||
func (s Service) ListWorkers(ctx context.Context, req *pbs.ListWorkersRequest) (*pbs.ListWorkersResponse, error) {
|
||||
if err := validateListRequest(req); err != nil {
|
||||
|
||||
@@ -9,13 +9,18 @@ import (
|
||||
)
|
||||
|
||||
type workerProxyServiceServer struct {
|
||||
pbs.UnimplementedServerCoordinationServiceServer
|
||||
pbs.UnimplementedSessionServiceServer
|
||||
pbs.UnsafeServerCoordinationServiceServer
|
||||
pbs.UnsafeSessionServiceServer
|
||||
|
||||
scsClient *atomic.Value
|
||||
ssClient pbs.SessionServiceClient
|
||||
}
|
||||
|
||||
var (
|
||||
_ pbs.ServerCoordinationServiceServer = (*workerProxyServiceServer)(nil)
|
||||
_ pbs.SessionServiceServer = (*workerProxyServiceServer)(nil)
|
||||
)
|
||||
|
||||
func NewWorkerProxyServiceServer(
|
||||
cc *grpc.ClientConn,
|
||||
scsClient *atomic.Value,
|
||||
@@ -26,11 +31,6 @@ func NewWorkerProxyServiceServer(
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
_ pbs.ServerCoordinationServiceServer = &workerProxyServiceServer{}
|
||||
_ pbs.SessionServiceServer = &workerProxyServiceServer{}
|
||||
)
|
||||
|
||||
func (ws *workerProxyServiceServer) Status(ctx context.Context, req *pbs.StatusRequest) (*pbs.StatusResponse, error) {
|
||||
resp, err := ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).Status(ctx, req)
|
||||
|
||||
@@ -43,6 +43,10 @@ func (ws *workerProxyServiceServer) Status(ctx context.Context, req *pbs.StatusR
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) ListHcpbWorkers(ctx context.Context, req *pbs.ListHcpbWorkersRequest) (*pbs.ListHcpbWorkersResponse, error) {
|
||||
return ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).ListHcpbWorkers(ctx, req)
|
||||
}
|
||||
|
||||
func (ws *workerProxyServiceServer) LookupSession(ctx context.Context, req *pbs.LookupSessionRequest) (*pbs.LookupSessionResponse, error) {
|
||||
return ws.ssClient.LookupSession(ctx, req)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user