From 5112ce896b54da9df35368c755e49ceba2c67a40 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 25 Oct 2026 22:46:47 +1100 Subject: [PATCH] fix(channelext): bound the extension broker server with service limits --- internal/app/archiemessaging/extension_channels.go | 3 ++- internal/infrastructure/channelext/channelext.go | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/app/archiemessaging/extension_channels.go b/internal/app/archiemessaging/extension_channels.go index 66c88fef9..de74b2d68 100644 --- a/internal/app/archiemessaging/extension_channels.go +++ b/internal/app/archiemessaging/extension_channels.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/go-hclog" + "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/channels" "github.com/samcharles93/archie-core/internal/domain/storepkg" "github.com/samcharles93/archie-core/internal/infrastructure/channelext" @@ -94,5 +95,5 @@ func buildExtensionChannel(ctx context.Context, host *extension.Host, source ext resolved[name] = secretValue } spec := extension.Spec{Name: "channel/" + pkg.Name, Path: binary, SHA256: sum, Env: slices.Clone(pkg.AcceptedAuthority.Env), Egress: slices.Clone(pkg.AcceptedAuthority.EgressHosts)} - return channelext.New(host, pkg.Name, spec, plain, resolved), nil + return channelext.New(host, pkg.Name, spec, plain, resolved, servicekit.ServerLimits()), nil } diff --git a/internal/infrastructure/channelext/channelext.go b/internal/infrastructure/channelext/channelext.go index 8866267b3..896c0a3dd 100644 --- a/internal/infrastructure/channelext/channelext.go +++ b/internal/infrastructure/channelext/channelext.go @@ -10,6 +10,7 @@ import ( "errors" "fmt" "io" + "slices" goplugin "github.com/hashicorp/go-plugin" "google.golang.org/grpc" @@ -55,12 +56,14 @@ type Channel struct { spec extension.Spec settings map[string]string secrets map[string]string + limits []grpc.ServerOption } // New returns a Channel that launches spec on Start. secrets are the resolved -// values of the settings' _ref entries. -func New(host *extension.Host, name string, spec extension.Spec, settings, secrets map[string]string) *Channel { - return &Channel{name: name, host: host, spec: spec, settings: settings, secrets: secrets} +// values of the settings' _ref entries. limits bound the broker server the +// extension dials back into, as on every service server. +func New(host *extension.Host, name string, spec extension.Spec, settings, secrets map[string]string, limits []grpc.ServerOption) *Channel { + return &Channel{name: name, host: host, spec: spec, settings: settings, secrets: secrets, limits: limits} } func (c *Channel) Name() string { return c.name } @@ -81,7 +84,7 @@ func (c *Channel) Start(ctx context.Context, chat messaging.ChatContract, lifecy id := ext.broker.NextId() go ext.broker.AcceptAndServe(id, func(opts []grpc.ServerOption) *grpc.Server { - server := grpc.NewServer(opts...) + server := grpc.NewServer(append(slices.Clone(c.limits), opts...)...) gatewayrpc.RegisterServer(server, restricted{chat}, nil, gatewayrpc.Catalog{}) return server })