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>
175 lines
8.2 KiB
Go
175 lines
8.2 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.6.2
|
|
// - protoc v6.33.4
|
|
// source: webhook_ingestion.proto
|
|
|
|
package webhookingestion
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the grpc package it is being compiled against.
|
|
// Requires gRPC-Go v1.64.0 or later.
|
|
const _ = grpc.SupportPackageIsVersion9
|
|
|
|
const (
|
|
WebhookIngestion_StreamEvents_FullMethodName = "/ration.webhookingestion.v1.WebhookIngestion/StreamEvents"
|
|
)
|
|
|
|
// WebhookIngestionClient is the client API for WebhookIngestion service.
|
|
//
|
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
//
|
|
// WebhookIngestion is an internal-only service (docs/SCALE-EXPANSION.md
|
|
// section 1): a direct extraction of services/gateway's old
|
|
// internal/airwallex/webhook.go (HMAC signature verification + envelope
|
|
// parsing) and internal/httpserver/webhooks.go (the HTTP listener and
|
|
// the "mark the matching deposit received" business logic). It receives
|
|
// Airwallex webhook deliveries over its own plain HTTP listener
|
|
// (WEBHOOK_INGESTION_HTTP_ADDR — gRPC is for the internal surface below,
|
|
// not for inbound Airwallex deliveries, which are plain signed HTTP
|
|
// POSTs per Airwallex's own webhook contract) and publishes normalized
|
|
// events onto a simple in-process event bus.
|
|
//
|
|
// docs/SCALE-EXPANSION.md section 1 calls this bus a placeholder: "a
|
|
// simple internal event bus for now — document where a real deployment
|
|
// would swap in SQS/Kafka." Recorded here: a real deployment running
|
|
// more than one webhook-ingestion replica needs a shared broker (SQS
|
|
// FIFO keyed by tenant_id, or a Kafka topic partitioned the same way) so
|
|
// every subscriber sees every event exactly once regardless of which
|
|
// replica received the originating webhook — this in-process Go-channel
|
|
// bus only fans out to subscribers of *this* process, which is fine for
|
|
// the single-replica deployment this project ships today but is the
|
|
// first thing to swap out before running N > 1 replicas for real.
|
|
type WebhookIngestionClient interface {
|
|
// StreamEvents lets another internal service (services/gateway, to
|
|
// merge into its own activity feed) subscribe to every normalized
|
|
// event this service publishes, optionally filtered to one tenant.
|
|
StreamEvents(ctx context.Context, in *StreamEventsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[NormalizedEvent], error)
|
|
}
|
|
|
|
type webhookIngestionClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewWebhookIngestionClient(cc grpc.ClientConnInterface) WebhookIngestionClient {
|
|
return &webhookIngestionClient{cc}
|
|
}
|
|
|
|
func (c *webhookIngestionClient) StreamEvents(ctx context.Context, in *StreamEventsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[NormalizedEvent], error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
stream, err := c.cc.NewStream(ctx, &WebhookIngestion_ServiceDesc.Streams[0], WebhookIngestion_StreamEvents_FullMethodName, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
x := &grpc.GenericClientStream[StreamEventsRequest, NormalizedEvent]{ClientStream: stream}
|
|
if err := x.ClientStream.SendMsg(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := x.ClientStream.CloseSend(); err != nil {
|
|
return nil, err
|
|
}
|
|
return x, nil
|
|
}
|
|
|
|
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
|
type WebhookIngestion_StreamEventsClient = grpc.ServerStreamingClient[NormalizedEvent]
|
|
|
|
// WebhookIngestionServer is the server API for WebhookIngestion service.
|
|
// All implementations must embed UnimplementedWebhookIngestionServer
|
|
// for forward compatibility.
|
|
//
|
|
// WebhookIngestion is an internal-only service (docs/SCALE-EXPANSION.md
|
|
// section 1): a direct extraction of services/gateway's old
|
|
// internal/airwallex/webhook.go (HMAC signature verification + envelope
|
|
// parsing) and internal/httpserver/webhooks.go (the HTTP listener and
|
|
// the "mark the matching deposit received" business logic). It receives
|
|
// Airwallex webhook deliveries over its own plain HTTP listener
|
|
// (WEBHOOK_INGESTION_HTTP_ADDR — gRPC is for the internal surface below,
|
|
// not for inbound Airwallex deliveries, which are plain signed HTTP
|
|
// POSTs per Airwallex's own webhook contract) and publishes normalized
|
|
// events onto a simple in-process event bus.
|
|
//
|
|
// docs/SCALE-EXPANSION.md section 1 calls this bus a placeholder: "a
|
|
// simple internal event bus for now — document where a real deployment
|
|
// would swap in SQS/Kafka." Recorded here: a real deployment running
|
|
// more than one webhook-ingestion replica needs a shared broker (SQS
|
|
// FIFO keyed by tenant_id, or a Kafka topic partitioned the same way) so
|
|
// every subscriber sees every event exactly once regardless of which
|
|
// replica received the originating webhook — this in-process Go-channel
|
|
// bus only fans out to subscribers of *this* process, which is fine for
|
|
// the single-replica deployment this project ships today but is the
|
|
// first thing to swap out before running N > 1 replicas for real.
|
|
type WebhookIngestionServer interface {
|
|
// StreamEvents lets another internal service (services/gateway, to
|
|
// merge into its own activity feed) subscribe to every normalized
|
|
// event this service publishes, optionally filtered to one tenant.
|
|
StreamEvents(*StreamEventsRequest, grpc.ServerStreamingServer[NormalizedEvent]) error
|
|
mustEmbedUnimplementedWebhookIngestionServer()
|
|
}
|
|
|
|
// UnimplementedWebhookIngestionServer must be embedded to have
|
|
// forward compatible implementations.
|
|
//
|
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
// pointer dereference when methods are called.
|
|
type UnimplementedWebhookIngestionServer struct{}
|
|
|
|
func (UnimplementedWebhookIngestionServer) StreamEvents(*StreamEventsRequest, grpc.ServerStreamingServer[NormalizedEvent]) error {
|
|
return status.Error(codes.Unimplemented, "method StreamEvents not implemented")
|
|
}
|
|
func (UnimplementedWebhookIngestionServer) mustEmbedUnimplementedWebhookIngestionServer() {}
|
|
func (UnimplementedWebhookIngestionServer) testEmbeddedByValue() {}
|
|
|
|
// UnsafeWebhookIngestionServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to WebhookIngestionServer will
|
|
// result in compilation errors.
|
|
type UnsafeWebhookIngestionServer interface {
|
|
mustEmbedUnimplementedWebhookIngestionServer()
|
|
}
|
|
|
|
func RegisterWebhookIngestionServer(s grpc.ServiceRegistrar, srv WebhookIngestionServer) {
|
|
// If the following call panics, it indicates UnimplementedWebhookIngestionServer was
|
|
// embedded by pointer and is nil. This will cause panics if an
|
|
// unimplemented method is ever invoked, so we test this at initialization
|
|
// time to prevent it from happening at runtime later due to I/O.
|
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
t.testEmbeddedByValue()
|
|
}
|
|
s.RegisterService(&WebhookIngestion_ServiceDesc, srv)
|
|
}
|
|
|
|
func _WebhookIngestion_StreamEvents_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
m := new(StreamEventsRequest)
|
|
if err := stream.RecvMsg(m); err != nil {
|
|
return err
|
|
}
|
|
return srv.(WebhookIngestionServer).StreamEvents(m, &grpc.GenericServerStream[StreamEventsRequest, NormalizedEvent]{ServerStream: stream})
|
|
}
|
|
|
|
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
|
type WebhookIngestion_StreamEventsServer = grpc.ServerStreamingServer[NormalizedEvent]
|
|
|
|
// WebhookIngestion_ServiceDesc is the grpc.ServiceDesc for WebhookIngestion service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var WebhookIngestion_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "ration.webhookingestion.v1.WebhookIngestion",
|
|
HandlerType: (*WebhookIngestionServer)(nil),
|
|
Methods: []grpc.MethodDesc{},
|
|
Streams: []grpc.StreamDesc{
|
|
{
|
|
StreamName: "StreamEvents",
|
|
Handler: _WebhookIngestion_StreamEvents_Handler,
|
|
ServerStreams: true,
|
|
},
|
|
},
|
|
Metadata: "webhook_ingestion.proto",
|
|
}
|