caelum0x 77324a7b50 feat(ration): split gateway into auth/tenant-registry/card-issuance/webhook-ingestion
Phase 2 service decomposition per docs/SCALE-EXPANSION.md section 1: extracts
internal/{airwallex,bridge,card,tenant,httpserver} out of the monolithic
gateway into four independently deployable gRPC services (each own go.mod,
Dockerfile, and tests), with gateway now a thin BFF that fans out through new
cardissuanceclient/webhookeventsclient gRPC clients. gateway.proto's external
surface is unchanged — agent/tui/cli still talk to gateway exactly as before.

Verified: all 10 go.work modules build and `go test ./...` passes across
every one, including the new gateway client packages against the live split
services (via `make build && make test`).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-19 12:25:41 +03:00

58 lines
2.0 KiB
Go

// Package grpcserver implements tenant_registry.proto's TenantRegistry
// service by delegating to internal/tenant — this package is the one
// place that translates between wire types (pkg/pb/tenantregistry,
// pkg/pb/ledger) and internal/tenant's Go-native API.
package grpcserver
import (
"context"
ledgerpb "github.com/caelum0x/ration/pkg/pb/ledger"
tenantregistrypb "github.com/caelum0x/ration/pkg/pb/tenantregistry"
"github.com/caelum0x/ration/services/tenant-registry/internal/tenant"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// Server implements tenantregistrypb.TenantRegistryServer.
type Server struct {
tenantregistrypb.UnimplementedTenantRegistryServer
svc *tenant.Service
}
// New wraps a *tenant.Service as a TenantRegistryServer.
func New(svc *tenant.Service) *Server {
return &Server{svc: svc}
}
// CreateTenant implements tenantregistrypb.TenantRegistryServer.
func (s *Server) CreateTenant(ctx context.Context, req *tenantregistrypb.CreateTenantRequest) (*ledgerpb.Tenant, error) {
t, err := s.svc.Create(ctx, req.GetName(), req.GetCurrency(), req.GetReserveFloorMinorUnits())
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
return t, nil
}
// GetTenant implements tenantregistrypb.TenantRegistryServer.
func (s *Server) GetTenant(ctx context.Context, req *tenantregistrypb.GetTenantRequest) (*ledgerpb.Tenant, error) {
t, err := s.svc.Get(ctx, req.GetId())
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
return t, nil
}
// ListTenants implements tenantregistrypb.TenantRegistryServer.
func (s *Server) ListTenants(ctx context.Context, req *tenantregistrypb.ListTenantsRequest) (*tenantregistrypb.ListTenantsResponse, error) {
resp, err := s.svc.List(ctx, req.GetPageSize(), req.GetPageToken())
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return &tenantregistrypb.ListTenantsResponse{
Tenants: resp.GetTenants(),
NextPageToken: resp.GetNextPageToken(),
}, nil
}