detached 1f9680c

refactor(broker): relay raw envelopes through one core stream port

The broker core admits BrokerCoreService connections whose streams carry opaque session envelopes end to end. Typed preview and observation decode through an injected SessionCodec, validated in serviceConfig. daemonmux logical connections carry raw envelopes only; the client keeps its typed BrokerService.
commit
1f9680c645f9bb0aa17e9f8b62aa277f13404ebb
author
brice · · 2026-09-23 16:24 UTC
parent
4e0fee9
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
36 files · +2540 -505
M internal/adapters/brokeripc/helpers_test.go +39 -17
@@ -1,6 +1,7 @@
11 package brokeripc
22
33 import (
4+ "bytes"
45 "context"
56 "encoding/binary"
67 "errors"
@@ -15,6 +16,7 @@ import (
1516 "github.com/stretchr/testify/require"
1617
1718 "github.com/bnema/vev/internal/adapters/brokerwire"
19+ "github.com/bnema/vev/internal/adapters/sessionwire"
1820 "github.com/bnema/vev/internal/domain"
1921 "github.com/bnema/vev/internal/ports"
2022 "github.com/bnema/vev/internal/protocol"
@@ -72,7 +74,7 @@ func attachmentRequest(stream ports.BrokerStreamID, admission ports.BrokerStream
7274
7375 // nextStreamID reads one fresh identity from the service's only allocator,
7476 // exactly as the composed supervisor and broker operations do.
75-func nextStreamID(t *testing.T, service ports.BrokerService) ports.BrokerStreamID {
77+func nextStreamID(t *testing.T, service ports.BrokerSession) ports.BrokerStreamID {
7678 t.Helper()
7779 stream, err := service.NextStreamID()
7880 require.NoError(t, err)
@@ -87,14 +89,14 @@ const membershipProbeEndpoint = "probe@host:22"
8789 // membership round trip after a stream-local or subscriber-local event: the
8890 // probe adds one host through the same delegated path a real caller uses and
8991 // asserts the registration comes back for exactly the requested endpoint.
90-func requireConnectionDelegates(t *testing.T, service ports.BrokerService) {
92+func requireConnectionDelegates(t *testing.T, service ports.BrokerSession) {
9193 t.Helper()
9294 require.NoError(t, connectionDelegates(context.Background(), service))
9395 }
9496
9597 // connectionDelegates is the error-returning form of requireConnectionDelegates,
9698 // safe to call from a test goroutine where FailNow is not.
97-func connectionDelegates(ctx context.Context, service ports.BrokerService) error {
99+func connectionDelegates(ctx context.Context, service ports.BrokerSession) error {
98100 ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
99101 defer cancel()
100102 registration, err := service.AddHost(ctx, membershipProbeEndpoint, testPolicy())
@@ -284,22 +286,38 @@ func (s *fakeSubscription) notify() {
284286 type fakeLogicalConn struct {
285287 fromClient chan protocol.ClientMessage
286288 toClient chan protocol.ServerMessage
287- done chan struct{}
288- once sync.Once
289- mu sync.Mutex
290- err error
291- closed bool
289+ // preamble carries the canned session preamble acceptance: the raw relay
290+ // forwards the client's preamble request like any other envelope.
291+ preamble chan []byte
292+ done chan struct{}
293+ once sync.Once
294+ mu sync.Mutex
295+ err error
296+ closed bool
292297 }
293298
294299 func newFakeLogicalConn() *fakeLogicalConn {
295300 return &fakeLogicalConn{
296301 fromClient: make(chan protocol.ClientMessage, 64),
297302 toClient: make(chan protocol.ServerMessage, 64),
303+ preamble: make(chan []byte, 1),
298304 done: make(chan struct{}),
299305 }
300306 }
301307
302-func (c *fakeLogicalConn) SendClient(message protocol.ClientMessage) error {
308+func (c *fakeLogicalConn) SendEnvelope(payload []byte) error {
309+ if request, err := sessionwire.EncodePreambleRequestForTest(); err == nil && bytes.Equal(payload, request) {
310+ response, err := sessionwire.EncodePreambleResponseForTest()
311+ if err != nil {
312+ return err
313+ }
314+ c.preamble <- response
315+ return nil
316+ }
317+ message, err := sessionwire.DecodeClientEnvelope(payload)
318+ if err != nil {
319+ return err
320+ }
303321 select {
304322 case c.fromClient <- message:
305323 return nil
@@ -308,20 +326,24 @@ func (c *fakeLogicalConn) SendClient(message protocol.ClientMessage) error {
308326 }
309327 }
310328
311-func (c *fakeLogicalConn) ReceiveServer() (protocol.ServerMessage, error) {
329+func (c *fakeLogicalConn) RecvEnvelope() ([]byte, error) {
312330 // A message already queued when Close ran must still be observed first: a
313331 // real carriage never reports the connection done before a message the peer
314332 // sent ahead of an orderly close has been delivered. Draining non-blocking
315333 // before the select keeps that ordering deterministic instead of racing a
316334 // buffered send against an already-closed done channel.
317335 select {
336+ case response := <-c.preamble:
337+ return response, nil
318338 case message := <-c.toClient:
319- return message, nil
339+ return sessionwire.EncodeServerMessage(message)
320340 default:
321341 }
322342 select {
343+ case response := <-c.preamble:
344+ return response, nil
323345 case message := <-c.toClient:
324- return message, nil
346+ return sessionwire.EncodeServerMessage(message)
325347 case <-c.done:
326348 if err := c.Err(); err != nil {
327349 return nil, err
@@ -487,7 +509,7 @@ func (c *fakeCore) SubscribePreview(ports.BrokerPreviewRequest) (ports.BrokerPre
487509 return newFakePreviewSubscription(), nil
488510 }
489511
490-func (c *fakeCore) OpenStream(_ context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
512+func (c *fakeCore) OpenEnvelopeStream(_ context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
491513 c.mu.Lock()
492514 defer c.mu.Unlock()
493515 if c.openErr != nil {
@@ -721,7 +743,7 @@ func newFakeAuthority(epoch ports.BrokerEpoch, snapshot ports.BrokerSnapshot) *f
721743 return &fakeAuthority{hub: newSnapshotHub(snapshot), epoch: epoch}
722744 }
723745
724-func (a *fakeAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) {
746+func (a *fakeAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) {
725747 if err := ctx.Err(); err != nil {
726748 return nil, err
727749 }
@@ -770,10 +792,10 @@ func startEndpoint(t *testing.T, cfg Config) *endpoint {
770792 }
771793
772794 // accept returns the next admitted session.
773-func (e *endpoint) accept() ports.BrokerService {
795+func (e *endpoint) accept() ports.BrokerCoreService {
774796 e.t.Helper()
775797 type result struct {
776- service ports.BrokerService
798+ service ports.BrokerCoreService
777799 err error
778800 }
779801 out := make(chan result, 1)
@@ -807,7 +829,7 @@ func (e *endpoint) dialWith(cfg Config) ports.BrokerService {
807829 }
808830
809831 // pair dials one client and accepts its session.
810-func (e *endpoint) pair() (ports.BrokerService, ports.BrokerService) {
832+func (e *endpoint) pair() (ports.BrokerService, ports.BrokerCoreService) {
811833 e.t.Helper()
812834 client := e.dial()
813835 session := e.accept()
M internal/adapters/brokeripc/listen_test.go +3 -3
@@ -27,7 +27,7 @@ type gatedAuthority struct {
2727 once sync.Once
2828 }
2929
30-func (a *gatedAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) {
30+func (a *gatedAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) {
3131 a.once.Do(func() { close(a.entered) })
3232 <-a.gate
3333 return a.inner.AdmitClient(ctx)
@@ -41,7 +41,7 @@ type ctxAuthority struct {
4141 once sync.Once
4242 }
4343
44-func (a *ctxAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) {
44+func (a *ctxAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) {
4545 a.once.Do(func() { close(a.entered) })
4646 <-ctx.Done()
4747 return nil, ctx.Err()
@@ -429,7 +429,7 @@ func TestStalledHandshakeDoesNotBlockOtherClients(t *testing.T) {
429429 func TestConcurrentDialAndClose(t *testing.T) {
430430 e := startEndpoint(t, Config{MaxClients: 8, HandshakeTimeout: 2 * time.Second})
431431
432- sessions := make(chan ports.BrokerService, 8)
432+ sessions := make(chan ports.BrokerCoreService, 8)
433433 go func() {
434434 defer close(sessions)
435435 for i := 0; i < cap(sessions); i++ {
M internal/adapters/brokeripc/preview_lifecycle_test.go +2 -2
@@ -57,7 +57,7 @@ func awaitPreviewChanged(t *testing.T, sub ports.BrokerPreviewSubscription) port
5757 // serverPreviewGeneration returns the server session's current preview
5858 // generation: it observes the same replacement bookkeeping startPreview
5959 // maintains, so a test can prove which generation the server holds current.
60-func serverPreviewGeneration(session ports.BrokerService) ports.BrokerPreviewGeneration {
60+func serverPreviewGeneration(session ports.BrokerCoreService) ports.BrokerPreviewGeneration {
6161 server, ok := session.(*serverSession)
6262 if !ok {
6363 return 0
@@ -68,7 +68,7 @@ func serverPreviewGeneration(session ports.BrokerService) ports.BrokerPreviewGen
6868 }
6969
7070 // serverPreviewOf returns the server session's current preview subscription.
71-func serverPreviewOf(session ports.BrokerService) ports.BrokerPreviewSubscription {
71+func serverPreviewOf(session ports.BrokerCoreService) ports.BrokerPreviewSubscription {
7272 server, ok := session.(*serverSession)
7373 if !ok {
7474 return nil
A internal/adapters/brokeripc/raw_stream_test.go +55 -0
@@ -0,0 +1,55 @@
1+package brokeripc
2+
3+import (
4+ "context"
5+ "encoding/binary"
6+ "io"
7+ "testing"
8+ "time"
9+
10+ "github.com/stretchr/testify/require"
11+)
12+
13+type rawRelayCore struct {
14+ received chan []byte
15+ done chan struct{}
16+}
17+
18+func (c *rawRelayCore) SendEnvelope(payload []byte) error {
19+ c.received <- append([]byte(nil), payload...)
20+ return nil
21+}
22+func (c *rawRelayCore) RecvEnvelope() ([]byte, error) { <-c.done; return nil, io.EOF }
23+func (c *rawRelayCore) Done() <-chan struct{} { return c.done }
24+func (c *rawRelayCore) Err() error { return nil }
25+func (c *rawRelayCore) Close() error {
26+ select {
27+ case <-c.done:
28+ default:
29+ close(c.done)
30+ }
31+ return nil
32+}
33+
34+func TestServerStreamRelaysOpaqueEnvelopes(t *testing.T) {
35+ core := &rawRelayCore{received: make(chan []byte, 1), done: make(chan struct{})}
36+ session := &serverSession{ctx: context.Background(), cfg: Config{}.withDefaults()}
37+ stream, err := newServerStream(session, 1, core)
38+ require.NoError(t, err)
39+ session.wg.Add(1)
40+ go stream.relayClient()
41+ payload := []byte{0xff, 0xfe, 0xfd, 0x80}
42+ frame := make([]byte, 4+len(payload))
43+ binary.BigEndian.PutUint32(frame[:4], uint32(len(payload)))
44+ copy(frame[4:], payload)
45+ require.NoError(t, stream.deliver(frame[:2]))
46+ require.NoError(t, stream.deliver(frame[2:]))
47+ select {
48+ case got := <-core.received:
49+ require.Equal(t, payload, got)
50+ case <-time.After(5 * time.Second):
51+ t.Fatal("opaque envelope not relayed")
52+ }
53+ stream.close(nil)
54+ session.wg.Wait()
55+}
M internal/adapters/brokeripc/server.go +6 -6
@@ -281,7 +281,7 @@ func (l *listener) classifyAdmissionFailure(err error) error {
281281 // credential, or an unsupported build) or a client that fails the preamble or
282282 // admission is isolated: that peer is dropped and the listener keeps serving.
283283 // The most recent refusal is available to diagnostics through refusal.
284-func (l *listener) Accept() (ports.BrokerService, error) {
284+func (l *listener) Accept() (ports.BrokerCoreService, error) {
285285 if l == nil {
286286 return nil, ErrListenerClosed
287287 }
@@ -466,7 +466,7 @@ type serverSession struct {
466466 epoch ports.BrokerEpoch
467467 scope brokerwire.Scope
468468 conn *brokerwire.Connection
469- core ports.BrokerService
469+ core ports.BrokerCoreService
470470 transport wire.BoundedTransport
471471 ceilings brokerwire.Ceilings
472472 cfg Config
@@ -513,7 +513,7 @@ type serverSession struct {
513513 done chan struct{}
514514 }
515515
516-var _ ports.BrokerService = (*serverSession)(nil)
516+var _ ports.BrokerCoreService = (*serverSession)(nil)
517517
518518 // registrationDeadline returns the absolute instant by which an accepted client
519519 // must send its Register: the accept-time handshake deadline that already
@@ -535,7 +535,7 @@ func registrationDeadline(ctx context.Context) time.Time {
535535 // registerDeadline is the absolute instant by which the client's Register must
536536 // arrive (the accept-time handshake deadline); the zero time disables the bound
537537 // and exists only for direct construction outside the listener.
538-func newServerSession(epoch ports.BrokerEpoch, transport wire.BoundedTransport, ceilings brokerwire.Ceilings, core ports.BrokerService, cfg Config, release func(), registerDeadline time.Time) (*serverSession, error) {
538+func newServerSession(epoch ports.BrokerEpoch, transport wire.BoundedTransport, ceilings brokerwire.Ceilings, core ports.BrokerCoreService, cfg Config, release func(), registerDeadline time.Time) (*serverSession, error) {
539539 if epoch == 0 || transport == nil || core == nil {
540540 return nil, ErrConfig
541541 }
@@ -983,14 +983,14 @@ func (s *serverSession) SubscribePreview(request ports.BrokerPreviewRequest) (po
983983 // allocated (NextStreamID) and is transmitted unchanged: this listener never
984984 // re-allocates a wire identity, whether the request arrives over the wire or
985985 // through this in-process delegate.
986-func (s *serverSession) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
986+func (s *serverSession) OpenEnvelopeStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
987987 if err := s.checkRequestScope(request.Epoch, request.Connection); err != nil {
988988 return nil, err
989989 }
990990 scoped := request
991991 scoped.Epoch = s.epoch
992992 scoped.Connection = s.scope.Connection
993- return s.core.OpenStream(ctx, scoped)
993+ return s.core.OpenEnvelopeStream(ctx, scoped)
994994 }
995995
996996 // CloseStream retires one scope-checked stream. An absent connection identity is
M internal/adapters/brokeripc/session_test.go +1 -1
@@ -110,7 +110,7 @@ func TestSessionCloseStreamFillsConnectionScope(t *testing.T) {
110110
111111 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
112112 defer cancel()
113- opened, err := session.OpenStream(ctx, openRequest(1))
113+ opened, err := session.OpenEnvelopeStream(ctx, openRequest(1))
114114 require.NoError(t, err)
115115 require.NotNil(t, opened)
116116
M internal/adapters/brokeripc/stream.go +23 -29
@@ -9,16 +9,14 @@ import (
99 "github.com/bnema/vev/internal/adapters/brokerwire"
1010 "github.com/bnema/vev/internal/adapters/sessionwire"
1111 "github.com/bnema/vev/internal/ports"
12+ "github.com/bnema/vev/internal/protocol/wire"
1213 )
1314
1415 // Logical stream bridging.
1516 //
16-// One brokerwire logical stream carries the typed session protocol between a
17-// client and the daemon behind the broker. The broker terminates both hops: the
18-// client's session connection is built by sessionwire over the stream's private
19-// bounded byte pipe, and the admitted broker core hands back its own typed
20-// connection to the daemon. Two relay goroutines carry typed messages between
21-// them, so no session byte is ever reinterpreted here.
17+// One brokerwire logical stream carries the session protocol between client
18+// and daemon. The broker relays complete opaque envelope payloads through
19+// bounded framed carriages; neither preamble nor session message is decoded.
2220 //
2321 // Identity and cancellation stay per stream: a stream the core loses, a stream
2422 // whose local consumer stalled, and a stream the peer closed each settle alone,
@@ -29,10 +27,9 @@ import (
2927 type serverStream struct {
3028 session *serverSession
3129 id ports.BrokerStreamID
32- core ports.BrokerLogicalConnection
30+ core ports.BrokerEnvelopeStream
3331 pipe *streamPipe
3432 carriage *carriage
35- wire ports.ServerConnection
3633
3734 mu sync.Mutex
3835 closed bool
@@ -40,17 +37,13 @@ type serverStream struct {
4037 }
4138
4239 // newServerStream builds one bridged stream over the admitted core connection.
43-func newServerStream(s *serverSession, id ports.BrokerStreamID, core ports.BrokerLogicalConnection) (*serverStream, error) {
40+func newServerStream(s *serverSession, id ports.BrokerStreamID, core ports.BrokerEnvelopeStream) (*serverStream, error) {
4441 if s == nil || core == nil || id == 0 {
4542 return nil, ErrConfig
4643 }
4744 st := &serverStream{session: s, id: id, core: core, done: make(chan struct{})}
4845 st.pipe = newStreamPipe(s.cfg.StreamInboundChunks, s.cfg.StreamInboundBytes, st.sendChunk)
4946 st.carriage = newCarriage(st.pipe)
50- st.wire = sessionwire.NewServerConnection(st.carriage)
51- if st.wire == nil {
52- return nil, ErrConfig
53- }
5447 return st, nil
5548 }
5649
@@ -85,34 +78,36 @@ func (st *serverStream) start() {
8578 go st.watchCore()
8679 }
8780
88-// relayClient carries client-to-daemon messages from the wire session
89-// connection to the admitted core connection.
81+// relayClient carries complete client envelopes without decoding.
9082 func (st *serverStream) relayClient() {
9183 defer st.session.wg.Done()
9284 for {
93- message, err := st.wire.ReceiveClient()
85+ envelope, err := st.carriage.RecvBounded(wire.AbsoluteEnvelopeLimit)
9486 if err != nil {
9587 st.fail(cancelOrCause(st.session.ctx, streamFailure(err)))
9688 return
9789 }
98- if err := st.core.SendClient(message); err != nil {
99- st.fail(err)
90+ if err := st.core.SendEnvelope(envelope.Payload); err != nil {
91+ st.fail(coreFailure(st.core, err))
10092 return
10193 }
10294 }
10395 }
10496
105-// relayServer carries daemon-to-client messages from the admitted core
106-// connection to the wire session connection.
97+// relayServer carries complete daemon envelopes without decoding.
10798 func (st *serverStream) relayServer() {
10899 defer st.session.wg.Done()
109100 for {
110- message, err := st.core.ReceiveServer()
101+ payload, err := st.core.RecvEnvelope()
111102 if err != nil {
112103 st.fail(coreFailure(st.core, err))
113104 return
114105 }
115- if err := st.wire.SendServer(message); err != nil {
106+ if len(payload) == 0 || len(payload) > wire.AbsoluteEnvelopeLimit {
107+ st.fail(ErrProtocol)
108+ return
109+ }
110+ if err := st.carriage.Send(wire.Envelope{Payload: payload}); err != nil {
116111 st.fail(streamFailure(err))
117112 return
118113 }
@@ -121,10 +116,10 @@ func (st *serverStream) relayServer() {
121116
122117 // watchCore publishes the core connection's terminal outcome even when no read
123118 // is in flight. It settles the stream itself only for a failure: an orderly
124-// core end (Err()==nil) is left to relayServer, whose own core.ReceiveServer()
119+// core end (Err()==nil) is left to relayServer, whose own core.RecvEnvelope()
125120 // call observes the same terminal outcome right after forwarding any reply
126121 // that was already in flight, and settles the stream from there. Settling here
127-// on every Done would race relayServer's in-flight wire.SendServer and could
122+// on every Done would race relayServer's in-flight carriage.Send and could
128123 // close the carriage while a received reply is still being written out to the
129124 // client, discarding it.
130125 func (st *serverStream) watchCore() {
@@ -147,8 +142,7 @@ func (st *serverStream) fail(err error) {
147142 }
148143
149144 // close releases the stream exactly once: the pipe unblocks a stalled reader,
150-// the wire session connection releases the carriage, and the core connection is
151-// closed. It reports whether this call was the one that settled the stream.
145+// the carriage joins its writer, and the core connection closes.
152146 func (st *serverStream) close(cause error) bool {
153147 if st == nil {
154148 return false
@@ -161,7 +155,7 @@ func (st *serverStream) close(cause error) bool {
161155 st.closed = true
162156 st.mu.Unlock()
163157 st.pipe.closeWith(cause)
164- _ = st.wire.Close()
158+ _ = st.carriage.Close()
165159 _ = st.core.Close()
166160 close(st.done)
167161 return true
@@ -178,7 +172,7 @@ func streamFailure(err error) error {
178172
179173 // coreFailure classifies one core connection outcome. The core's typed terminal
180174 // error wins; an orderly end is a peer close.
181-func coreFailure(core ports.BrokerLogicalConnection, err error) error {
175+func coreFailure(core ports.BrokerEnvelopeStream, err error) error {
182176 if err == nil && core != nil {
183177 err = core.Err()
184178 }
@@ -221,7 +215,7 @@ func (s *serverSession) startStream(m brokerwire.OpenStream) {
221215 s.wg.Add(1)
222216 go func() {
223217 defer s.wg.Done()
224- core, err := s.core.OpenStream(s.ctx, request)
218+ core, err := s.core.OpenEnvelopeStream(s.ctx, request)
225219 if err != nil {
226220 _, _ = s.conn.CloseStream(m.Stream)
227221 if sendErr := s.refuseStream(m.Stream, err); sendErr != nil {
M internal/adapters/daemonmux/connector.go +1 -1
@@ -305,7 +305,7 @@ func (c *PhysicalConnection) Policy() ports.BrokerPolicy {
305305 // the LogicalConnector. A policy that differs in any field is refused as a
306306 // conflicting policy without touching the carriage, so a physical connection
307307 // can never multiplex a stream under a policy it did not negotiate.
308-func (c *PhysicalConnection) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
308+func (c *PhysicalConnection) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
309309 if c == nil || c.logical == nil {
310310 return nil, ports.BrokerError{Code: ports.BrokerErrorIncompatible, Cause: ErrLogicalConfig}
311311 }
M internal/adapters/daemonmux/connector_test.go +4 -4
@@ -292,7 +292,7 @@ func TestEndpointConnectorExposesAuthorityAndPolicyGuard(t *testing.T) {
292292 require.Equal(t, domain.RemoteFailureNone, physical.FailureKind())
293293
294294 // A mismatched request policy is refused before the wire is touched.
295- _, err = physical.OpenStream(context.Background(), muxOpenRequest(1, alternatePolicy(binding.Policy())))
295+ _, err = openTyped(physical, context.Background(), muxOpenRequest(1, alternatePolicy(binding.Policy())))
296296 require.Error(t, err)
297297 var typed ports.BrokerError
298298 require.ErrorAs(t, err, &typed)
@@ -300,7 +300,7 @@ func TestEndpointConnectorExposesAuthorityAndPolicyGuard(t *testing.T) {
300300 require.Zero(t, server.acceptedCount(), "a policy-mismatched open is never admitted")
301301
302302 // The matching open is admitted and usable over the real carriage.
303- logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
303+ logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy()))
304304 require.NoError(t, err)
305305 server.awaitAccepted(t, 1)
306306 require.NoError(t, logical.SendClient(protocol.Ping{}))
@@ -334,7 +334,7 @@ func TestEndpointConnectorDetachesSetupContext(t *testing.T) {
334334 cancel()
335335 // The setup context ended; the pooled connection must still work.
336336 require.False(t, channelClosed(physical.Done()))
337- logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
337+ logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy()))
338338 require.NoError(t, err)
339339 server.awaitAccepted(t, 1)
340340 require.NoError(t, logical.SendClient(protocol.Ping{}))
@@ -360,7 +360,7 @@ func TestPhysicalDoneBeforeLogicalLoss(t *testing.T) {
360360 t.Cleanup(func() { _ = physical.Close() })
361361 require.NoError(t, server.awaitAdoption(t))
362362
363- logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
363+ logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy()))
364364 require.NoError(t, err)
365365 server.awaitAccepted(t, 1)
366366 require.False(t, channelClosed(physical.Done()))
M internal/adapters/daemonmux/listener_test.go +2 -1
@@ -285,8 +285,9 @@ func servePongs(conn ports.ServerConnection) error {
285285 }
286286
287287 // listenerRoundTrip proves one typed exchange on a logical connection.
288-func listenerRoundTrip(t *testing.T, conn ports.ClientConnection) {
288+func listenerRoundTrip(t *testing.T, stream ports.BrokerEnvelopeStream) {
289289 t.Helper()
290+ conn := asTyped(stream)
290291 require.NoError(t, conn.SendClient(protocol.Ping{}))
291292 message, err := conn.ReceiveServer()
292293 require.NoError(t, err)
M internal/adapters/daemonmux/logical_conn.go +32 -93
@@ -1,12 +1,8 @@
1-// Typed logical connections over one physical Pump.
1+// Logical connections over one physical Pump.
22 //
3-// A LogicalConnection is one independently cancellable typed session stream
4-// multiplexed over one physical daemonmux Pump. It implements
5-// ports.BrokerLogicalConnection by embedding the typed ports.ClientConnection
6-// that sessionwire builds on top of the mux stream, so the typed session
7-// protocol (4-byte framed Protobuf envelopes, the session preamble, and every
8-// semantic conversion) is reused verbatim: daemonmux never reinterprets a
9-// session message.
3+// A LogicalConnection carries complete raw session envelopes across the broker,
4+// without decoding them. Typed preview and observation are adapted by their
5+// consumers, never by this mux connection.
106 //
117 // The carriage between the two is a private, ordered, bounded byte stream
128 // (muxStreamPipe). Its read side pulls already-queued chunks from the pump
@@ -24,10 +20,6 @@
2420 // resets exactly that stream (one mux Reset) and leaves every sibling and the
2521 // physical connection untouched. Done, Err, and a physical-loss
2622 // ports.BrokerStreamLost are published once and stay stable afterwards.
27-//
28-// The narrow HandshakePlumbing seam exposes the accepted absolute 15 s
29-// handshake deadline and a completion hook from the wrapped session
30-// connection without changing ports or the daemon.
3123 package daemonmux
3224
3325 import (
@@ -35,13 +27,10 @@ import (
3527 "errors"
3628 "io"
3729 "sync"
38- "time"
3930
40- "github.com/bnema/vev/internal/adapters/sessionwire"
4131 "github.com/bnema/vev/internal/adapters/streamframe"
4232 "github.com/bnema/vev/internal/domain"
4333 "github.com/bnema/vev/internal/ports"
44- "github.com/bnema/vev/internal/protocol"
4534 "github.com/bnema/vev/internal/protocol/wire"
4635 )
4736
@@ -241,13 +230,9 @@ func discardQueuedInbound(pump *Pump, physical PhysicalStreamID) {
241230 }
242231 }
243232
244-// LogicalConnection is one typed client-side logical stream over a physical
245-// Pump. It implements ports.BrokerLogicalConnection: the embedded typed
246-// ports.ClientConnection carries the session protocol, while Close, Done, and
247-// Err add the stream lifecycle. It is safe for concurrent use.
233+// LogicalConnection is one client-side logical stream over a physical Pump.
234+// It implements the raw envelope port; Close, Done and Err manage its lifetime.
248235 type LogicalConnection struct {
249- ports.ClientConnection
250-
251236 pump *Pump
252237 ref StreamRef
253238 pipe *muxStreamPipe
@@ -258,22 +243,16 @@ type LogicalConnection struct {
258243 // keeps its exact cause even after the record is evicted.
259244 cause *terminalState
260245
261- terminal *terminalState
262- // plumbing is the wrapped session connection's handshake seam, resolved
263- // once at construction; nil when the wrapped connection lacks it.
264- plumbing HandshakePlumbing
265- // deadline is the exact absolute handshake deadline of the wrapped session
266- // connection, resolved once at construction.
267- deadline time.Time
246+ terminal *terminalState
268247 watchDone chan struct{}
269248 closeOnce sync.Once
270249 closeErr error
271250 }
272251
273-var _ ports.BrokerLogicalConnection = (*LogicalConnection)(nil)
252+var _ ports.BrokerEnvelopeStream = (*LogicalConnection)(nil)
274253
275-// newLogicalConnection builds the typed session channel over one confirmed
276-// open stream and starts the terminal watcher. It never blocks. cause is the
254+// newLogicalConnection builds the framed carriage over one confirmed open
255+// stream and starts the terminal watcher. It never blocks. cause is the
277256 // stream's retained terminal authority, captured at open so the connection
278257 // reports its exact outcome independent of the engine's bounded record.
279258 func newLogicalConnection(pump *Pump, ref StreamRef, streamDone <-chan struct{}, cause *terminalState) *LogicalConnection {
@@ -281,21 +260,14 @@ func newLogicalConnection(pump *Pump, ref StreamRef, streamDone <-chan struct{},
281260 pipe := newMuxStreamPipe(pump, ref.Physical, limit, streamDone)
282261 raw := newMuxTransport(pipe)
283262 connection := &LogicalConnection{
284- ClientConnection: sessionwire.NewClientConnection(raw),
285- pump: pump,
286- ref: ref,
287- pipe: pipe,
288- raw: raw,
289- stream: streamDone,
290- cause: cause,
291- terminal: newTerminalState(),
292- watchDone: make(chan struct{}),
293- }
294- if plumbing, ok := connection.ClientConnection.(HandshakePlumbing); ok {
295- connection.plumbing = plumbing
296- connection.deadline = plumbing.HandshakeDeadline()
297- } else {
298- connection.deadline = time.Now().Add(protocol.HandshakeTimeout)
263+ pump: pump,
264+ ref: ref,
265+ pipe: pipe,
266+ raw: raw,
267+ stream: streamDone,
268+ cause: cause,
269+ terminal: newTerminalState(),
270+ watchDone: make(chan struct{}),
299271 }
300272 go connection.watch()
301273 return connection
@@ -304,25 +276,6 @@ func newLogicalConnection(pump *Pump, ref StreamRef, streamDone <-chan struct{},
304276 // Ref returns the complete stream reference recorded at admission.
305277 func (c *LogicalConnection) Ref() StreamRef { return c.ref }
306278
307-// HandshakeDeadline returns the accepted absolute local deadline of the
308-// session handshake, plumbing the exact 15 s deadline the wrapped session
309-// connection started with. It is resolved once at construction and stable for
310-// the connection's lifetime.
311-func (c *LogicalConnection) HandshakeDeadline() time.Time { return c.deadline }
312-
313-// OnHandshakeComplete registers fn to run exactly once when the session
314-// handshake completes, plumbing the wrapped session connection's completion
315-// hook. Registering after completion runs fn immediately.
316-func (c *LogicalConnection) OnHandshakeComplete(fn func()) {
317- if c.plumbing != nil {
318- c.plumbing.OnHandshakeComplete(fn)
319- return
320- }
321- if fn != nil {
322- fn()
323- }
324-}
325-
326279 // Done returns the logical terminal channel independent of reads. It closes
327280 // exactly once, before Err becomes stable.
328281 func (c *LogicalConnection) Done() <-chan struct{} { return c.terminal.Done() }
@@ -335,39 +288,26 @@ func (c *LogicalConnection) Err() error { return c.terminal.Err() }
335288 // FailureKind classifies Err. It is None while open and for an orderly Close.
336289 func (c *LogicalConnection) FailureKind() domain.RemoteFailureKind { return c.terminal.FailureKind() }
337290
338-// SendClient sends one typed client message over the logical stream. It
339-// classifies a terminal transport failure and otherwise returns the session
340-// error verbatim.
341-func (c *LogicalConnection) SendClient(message protocol.ClientMessage) error {
291+func (c *LogicalConnection) SendEnvelope(payload []byte) error {
342292 if c.settled() {
343293 return c.terminalError()
344294 }
345- if err := c.ClientConnection.SendClient(message); err != nil {
346- if c.settled() {
347- return c.terminalError()
348- }
349- return err
295+ if len(payload) > wire.AbsoluteEnvelopeLimit {
296+ return streamframe.ErrTooLarge
350297 }
351- return nil
298+ return c.raw.Send(wire.Envelope{Payload: payload})
352299 }
353300
354-// ReceiveServer receives one typed server message. An orderly end of the inner
355-// stream returns io.EOF; any other inner-stream error is treated as a
356-// malformed session frame: exactly this stream is reset towards the peer, its
357-// terminal outcome is published, and the error is returned.
358-func (c *LogicalConnection) ReceiveServer() (protocol.ServerMessage, error) {
359- if c.settled() {
360- return nil, c.terminalError()
361- }
362- message, err := c.ClientConnection.ReceiveServer()
363- if err == nil {
364- return message, nil
365- }
366- if errors.Is(err, io.EOF) {
367- c.syncFromEngine()
368- return nil, c.terminalError()
301+func (c *LogicalConnection) RecvEnvelope() ([]byte, error) {
302+ envelope, err := c.raw.Recv()
303+ if err != nil {
304+ if errors.Is(err, io.EOF) {
305+ c.syncFromEngine()
306+ return nil, c.terminalError()
307+ }
308+ return nil, c.abortMalformed(err)
369309 }
370- return nil, c.abortMalformed(err)
310+ return envelope.Payload, nil
371311 }
372312
373313 // Close independently closes the logical stream: it discards the inbound
@@ -660,8 +600,7 @@ func (s *muxStreamPipe) Close() error {
660600 }
661601
662602 // muxTransport adapts the ordered byte stream to wire.Transport: streamframe
663-// owns the 4-byte length framing, and sessionwire owns the typed conversion on
664-// top. Closing it closes the byte stream and joins streamframe's writer.
603+// owns the 4-byte length framing, and sessionwire owns any typed conversion at the consuming endpoint. Closing it closes the byte stream and joins streamframe's writer.
665604 type muxTransport struct {
666605 pipe *muxStreamPipe
667606 framer *streamframe.Framer
M internal/adapters/daemonmux/logical_conn_test.go +8 -56
@@ -318,13 +318,13 @@ func (a *daemonAcceptor) closePeers() {
318318 }
319319 }
320320
321-func openWithDeadline(t *testing.T, connector *LogicalConnector, stream int) *LogicalConnection {
321+func openWithDeadline(t *testing.T, connector *LogicalConnector, stream int) typedLogical {
322322 t.Helper()
323323 ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
324324 defer cancel()
325325 connection, err := connector.Open(ctx, controlRequest(stream))
326326 require.NoError(t, err)
327- return connection
327+ return typedLogical{typedStream: asTyped(connection), LogicalConnection: connection}
328328 }
329329
330330 // watchRegistered reports whether the pump still holds an inbound watch entry
@@ -406,7 +406,7 @@ func TestLogicalTwoConnections(t *testing.T) {
406406 acceptor.start(PhysicalStreamID(i), deadline)
407407 }
408408
409- connections := make([]*LogicalConnection, 0, count)
409+ connections := make([]typedLogical, 0, count)
410410 for i := 1; i <= count; i++ {
411411 connection := openWithDeadline(t, connector, i)
412412 require.NoError(t, connection.SendClient(protocol.Ping{}), "connection %d", i)
@@ -487,11 +487,12 @@ func TestLogicalHundredConnectionsConcurrentAdmission(t *testing.T) {
487487 traffic.Add(1)
488488 go func(index int) {
489489 defer traffic.Done()
490- if err := connections[index].SendClient(protocol.Ping{}); err != nil {
490+ typed := asTyped(connections[index])
491+ if err := typed.SendClient(protocol.Ping{}); err != nil {
491492 trafficErrs[index] = err
492493 return
493494 }
494- message, err := connections[index].ReceiveServer()
495+ message, err := typed.ReceiveServer()
495496 if err != nil {
496497 trafficErrs[index] = err
497498 return
@@ -802,7 +803,7 @@ func TestLogicalPhysicalLossFanout(t *testing.T) {
802803 for i := 1; i <= count; i++ {
803804 acceptor.start(PhysicalStreamID(i), deadline)
804805 }
805- connections := make([]*LogicalConnection, 0, count)
806+ connections := make([]typedLogical, 0, count)
806807 for i := 1; i <= count; i++ {
807808 connection := openWithDeadline(t, connector, i)
808809 require.NoError(t, connection.SendClient(protocol.Ping{}))
@@ -832,55 +833,6 @@ func TestLogicalPhysicalLossFanout(t *testing.T) {
832833 require.Equal(t, domain.RemoteFailureTransport, brokerPump.FailureKind())
833834 }
834835
835-// TestLogicalHandshakeDeadlinePlumbing proves the accepted absolute 15 s
836-// handshake deadline and the completion hook are exposed without restarting a
837-// deadline.
838-func TestLogicalHandshakeDeadlinePlumbing(t *testing.T) {
839- brokerPump, daemonPump := newPairedPumps(t, DefaultMuxCeilings())
840- connector := mustConnector(t, brokerPump)
841- deadline := time.Now().Add(15 * time.Second)
842-
843- acceptor := newDaemonAcceptor(daemonPump, 1)
844- acceptor.start(1, deadline)
845-
846- connection := openWithDeadline(t, connector, 1)
847- require.NoError(t, acceptor.wait(1, deadline))
848-
849- accepted := connection.HandshakeDeadline()
850- require.False(t, accepted.IsZero())
851- require.WithinDuration(t, time.Now().Add(protocol.HandshakeTimeout), accepted, 5*time.Second)
852- require.Equal(t, accepted, connection.HandshakeDeadline(), "deadline is stable")
853-
854- completed := make(chan struct{}, 2)
855- connection.OnHandshakeComplete(func() { completed <- struct{}{} })
856- select {
857- case <-completed:
858- t.Fatal("completion hook fired before the handshake ran")
859- default:
860- }
861-
862- require.NoError(t, connection.SendClient(protocol.Ping{}))
863- message, err := connection.ReceiveServer()
864- require.NoError(t, err)
865- require.Equal(t, protocol.Pong{}, message)
866-
867- select {
868- case <-completed:
869- case <-time.After(5 * time.Second):
870- t.Fatal("completion hook did not fire after the handshake")
871- }
872-
873- // Registering after completion runs immediately.
874- late := make(chan struct{}, 1)
875- connection.OnHandshakeComplete(func() { late <- struct{}{} })
876- select {
877- case <-late:
878- case <-time.After(5 * time.Second):
879- t.Fatal("late completion hook did not run")
880- }
881-}
882-
883-// TestLogicalNoGoroutineLeak proves opening, using, and closing logical
884836 // connections leaves no goroutine behind.
885837 func TestLogicalNoGoroutineLeak(t *testing.T) {
886838 before := runtime.NumGoroutine()
@@ -894,7 +846,7 @@ func TestLogicalNoGoroutineLeak(t *testing.T) {
894846 for i := 1; i <= count; i++ {
895847 acceptor.start(PhysicalStreamID(i), deadline)
896848 }
897- connections := make([]*LogicalConnection, 0, count)
849+ connections := make([]typedLogical, 0, count)
898850 for i := 1; i <= count; i++ {
899851 connection := openWithDeadline(t, connector, i)
900852 require.NoError(t, connection.SendClient(protocol.Ping{}))
M internal/adapters/daemonmux/pool_integration_test.go +4 -4
@@ -75,12 +75,12 @@ func TestPoolSharesCompatibleAliasesOverOnePhysical(t *testing.T) {
7575 client, err := pool.RegisterClient()
7676 require.NoError(t, err)
7777
78- first, err := pool.OpenStream(context.Background(), p3cRemoteRequest(client, "aliasA@host:22", 1, policy))
78+ first, err := openTyped(pool, context.Background(), p3cRemoteRequest(client, "aliasA@host:22", 1, policy))
7979 require.NoError(t, err)
8080 require.NotNil(t, first)
8181 t.Cleanup(func() { _ = first.Close() })
8282
83- second, err := pool.OpenStream(context.Background(), p3cRemoteRequest(client, "aliasB@host:22", 2, policy))
83+ second, err := openTyped(pool, context.Background(), p3cRemoteRequest(client, "aliasB@host:22", 2, policy))
8484 require.NoError(t, err)
8585 require.NotNil(t, second)
8686 t.Cleanup(func() { _ = second.Close() })
@@ -114,7 +114,7 @@ func TestPoolRefusesConflictingPolicyWithoutDial(t *testing.T) {
114114
115115 client, err := pool.RegisterClient()
116116 require.NoError(t, err)
117- _, err = pool.OpenStream(context.Background(), p3cRemoteRequest(client, "aliasA@host:22", 1, alternatePolicy(binding.Policy())))
117+ _, err = openTyped(pool, context.Background(), p3cRemoteRequest(client, "aliasA@host:22", 1, alternatePolicy(binding.Policy())))
118118 require.Error(t, err)
119119 var typed ports.BrokerError
120120 require.ErrorAs(t, err, &typed)
@@ -142,7 +142,7 @@ func TestPoolSurfacesPhysicalLossPerStream(t *testing.T) {
142142
143143 client, err := pool.RegisterClient()
144144 require.NoError(t, err)
145- stream, err := pool.OpenStream(context.Background(), p3cRemoteRequest(client, "aliasA@host:22", 1, policy))
145+ stream, err := openTyped(pool, context.Background(), p3cRemoteRequest(client, "aliasA@host:22", 1, policy))
146146 require.NoError(t, err)
147147 server.awaitAccepted(t, 1)
148148
M internal/adapters/daemonmux/quic_carriage_test.go +7 -7
@@ -195,10 +195,10 @@ func TestQUICCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) {
195195 require.NoError(t, daemon.awaitAdoption(t))
196196
197197 // Two independent typed admissions over the one physical carriage.
198- first, err := physical.OpenStream(context.Background(), muxOpenRequest(1, policy))
198+ first, err := openTyped(physical, context.Background(), muxOpenRequest(1, policy))
199199 require.NoError(t, err)
200200 t.Cleanup(func() { _ = first.Close() })
201- second, err := physical.OpenStream(context.Background(), muxOpenRequest(2, policy))
201+ second, err := openTyped(physical, context.Background(), muxOpenRequest(2, policy))
202202 require.NoError(t, err)
203203 t.Cleanup(func() { _ = second.Close() })
204204 daemon.awaitQUICAccepted(t, 2)
@@ -219,7 +219,7 @@ func TestQUICCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) {
219219 wg.Add(1)
220220 go func(i int) {
221221 defer wg.Done()
222- connections[i], openErrs[i] = physical.OpenStream(context.Background(), muxOpenRequest(uint64(3+i), policy))
222+ connections[i], openErrs[i] = openTyped(physical, context.Background(), muxOpenRequest(uint64(3+i), policy))
223223 }(i)
224224 }
225225 wg.Wait()
@@ -375,11 +375,11 @@ func TestQUICCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) {
375375
376376 lost := make([]ports.BrokerLogicalConnection, 3)
377377 for i := range lost {
378- lost[i], err = physicalA.OpenStream(context.Background(), muxOpenRequest(uint64(i+1), policy))
378+ lost[i], err = openTyped(physicalA, context.Background(), muxOpenRequest(uint64(i+1), policy))
379379 require.NoError(t, err, "stream %d", i+1)
380380 t.Cleanup(func() { _ = lost[i].Close() })
381381 }
382- survivor, err := physicalB.OpenStream(context.Background(), muxOpenRequest(1, policy))
382+ survivor, err := openTyped(physicalB, context.Background(), muxOpenRequest(1, policy))
383383 require.NoError(t, err)
384384 t.Cleanup(func() { _ = survivor.Close() })
385385 daemon.awaitQUICAccepted(t, 4)
@@ -429,7 +429,7 @@ func TestQUICCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) {
429429 "the lost QUIC physical child was never reaped")
430430
431431 // The lost physical refuses a fresh stream.
432- _, err = physicalA.OpenStream(context.Background(), muxOpenRequest(9, policy))
432+ _, err = openTyped(physicalA, context.Background(), muxOpenRequest(9, policy))
433433 require.Error(t, err)
434434 }
435435
@@ -455,7 +455,7 @@ func TestQUICCarriageSetupContextDetachedFromPhysicalLifetime(t *testing.T) {
455455
456456 cancel()
457457 require.False(t, channelClosed(physical.Done()))
458- logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
458+ logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy()))
459459 require.NoError(t, err)
460460 t.Cleanup(func() { _ = logical.Close() })
461461 daemon.awaitQUICAccepted(t, 1)
A internal/adapters/daemonmux/raw_envelope_test.go +41 -0
@@ -0,0 +1,41 @@
1+package daemonmux
2+
3+import (
4+ "bytes"
5+ "context"
6+ "testing"
7+ "time"
8+
9+ "github.com/bnema/vev/internal/protocol/wire"
10+ "github.com/stretchr/testify/require"
11+)
12+
13+// TestLogicalRawEnvelopeRelay proves a logical connection carries opaque
14+// envelopes byte-for-byte in both directions without decoding them.
15+func TestLogicalRawEnvelopeRelay(t *testing.T) {
16+ broker, daemon := newPairedPumps(t, DefaultMuxCeilings())
17+ acceptor := newDaemonAcceptor(daemon, 0)
18+ acceptor.startBare(1, time.Now().Add(5*time.Second))
19+ ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
20+ defer cancel()
21+ conn, err := mustConnector(t, broker).Open(ctx, controlRequest(1))
22+ require.NoError(t, err)
23+ defer conn.Close()
24+ require.NoError(t, acceptor.wait(1, time.Now().Add(5*time.Second)))
25+
26+ payload := []byte{0xff, 0, 0x80, 7}
27+ require.NoError(t, conn.SendEnvelope(payload))
28+ status, ok := daemon.Engine().Status(conn.Ref().Physical)
29+ require.True(t, ok)
30+ peer := newMuxTransport(newMuxStreamPipe(daemon, conn.Ref().Physical, daemon.Ceilings().StreamChunkLimit, status.Done))
31+ defer peer.Close()
32+ got, err := peer.Recv()
33+ require.NoError(t, err)
34+ require.Equal(t, payload, got.Payload)
35+
36+ large := bytes.Repeat([]byte{0xfe}, 2048)
37+ require.NoError(t, peer.Send(wire.Envelope{Payload: large}))
38+ gotPayload, err := conn.RecvEnvelope()
39+ require.NoError(t, err)
40+ require.Equal(t, large, gotPayload)
41+}
M internal/adapters/daemonmux/ssh_carriage_test.go +7 -7
@@ -253,10 +253,10 @@ func TestSSHCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) {
253253 pid := sshMuxReadPID(t, pidPath)
254254
255255 // Two independent typed admissions over the one physical carriage.
256- first, err := physical.OpenStream(context.Background(), muxOpenRequest(1, policy))
256+ first, err := openTyped(physical, context.Background(), muxOpenRequest(1, policy))
257257 require.NoError(t, err)
258258 t.Cleanup(func() { _ = first.Close() })
259- second, err := physical.OpenStream(context.Background(), muxOpenRequest(2, policy))
259+ second, err := openTyped(physical, context.Background(), muxOpenRequest(2, policy))
260260 require.NoError(t, err)
261261 t.Cleanup(func() { _ = second.Close() })
262262 for _, stream := range []ports.BrokerLogicalConnection{first, second} {
@@ -276,7 +276,7 @@ func TestSSHCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) {
276276 wg.Add(1)
277277 go func(i int) {
278278 defer wg.Done()
279- connections[i], openErrs[i] = physical.OpenStream(context.Background(), muxOpenRequest(uint64(3+i), policy))
279+ connections[i], openErrs[i] = openTyped(physical, context.Background(), muxOpenRequest(uint64(3+i), policy))
280280 }(i)
281281 }
282282 wg.Wait()
@@ -332,12 +332,12 @@ func TestSSHCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) {
332332
333333 lost := make([]ports.BrokerLogicalConnection, 3)
334334 for i := range lost {
335- connection, err := physicalA.OpenStream(context.Background(), muxOpenRequest(uint64(i+1), policy))
335+ connection, err := openTyped(physicalA, context.Background(), muxOpenRequest(uint64(i+1), policy))
336336 require.NoError(t, err, "stream %d", i+1)
337337 lost[i] = connection
338338 t.Cleanup(func() { _ = connection.Close() })
339339 }
340- survivor, err := physicalB.OpenStream(context.Background(), muxOpenRequest(1, policy))
340+ survivor, err := openTyped(physicalB, context.Background(), muxOpenRequest(1, policy))
341341 require.NoError(t, err)
342342 t.Cleanup(func() { _ = survivor.Close() })
343343
@@ -383,7 +383,7 @@ func TestSSHCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) {
383383 require.Equal(t, protocol.Pong{}, message)
384384
385385 // The lost physical refuses a fresh stream.
386- _, err = physicalA.OpenStream(context.Background(), muxOpenRequest(9, policy))
386+ _, err = openTyped(physicalA, context.Background(), muxOpenRequest(9, policy))
387387 require.Error(t, err)
388388
389389 // The failed subprocess is reaped, not left a zombie.
@@ -409,7 +409,7 @@ func TestSSHCarriageSetupContextDetachedFromPhysicalLifetime(t *testing.T) {
409409 cancel()
410410
411411 require.False(t, channelClosed(physical.Done()))
412- logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
412+ logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy()))
413413 require.NoError(t, err)
414414 t.Cleanup(func() { _ = logical.Close() })
415415 require.NoError(t, logical.SendClient(protocol.Ping{}))
M internal/adapters/daemonmux/supervisor_test.go +9 -8
@@ -112,8 +112,9 @@ func TestServerSupervisorEnforcesAcceptedPolicyBeforeAdmission(t *testing.T) {
112112 require.NoError(t, err)
113113 require.NotNil(t, connection)
114114 server.awaitAccepted(t, 1)
115- require.NoError(t, connection.SendClient(protocol.Ping{}))
116- message, err := connection.ReceiveServer()
115+ typed := asTyped(connection)
116+ require.NoError(t, typed.SendClient(protocol.Ping{}))
117+ message, err := typed.ReceiveServer()
117118 require.NoError(t, err)
118119 require.Equal(t, protocol.Pong{}, message)
119120 }
@@ -152,7 +153,7 @@ func TestServerSupervisorDeliversFirstHelloDataFrame(t *testing.T) {
152153 accepted <- connection
153154 }()
154155
155- logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
156+ logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy()))
156157 require.NoError(t, err)
157158 var server ports.ServerConnection
158159 select {
@@ -220,7 +221,7 @@ func TestServerSupervisorStampsAcceptedOriginThroughAggregate(t *testing.T) {
220221 accepted <- connection
221222 }()
222223
223- logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
224+ logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy()))
224225 require.NoError(t, err)
225226 t.Cleanup(func() { _ = logical.Close() })
226227
@@ -292,9 +293,9 @@ func TestServerSupervisorServerLossIsolated(t *testing.T) {
292293 physicalB := connectRaw(t, clientB, endpoint)
293294 require.NoError(t, server.awaitAdoption(t))
294295
295- logicalA, err := physicalA.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
296+ logicalA, err := openTyped(physicalA, context.Background(), muxOpenRequest(1, binding.Policy()))
296297 require.NoError(t, err)
297- logicalB, err := physicalB.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy()))
298+ logicalB, err := openTyped(physicalB, context.Background(), muxOpenRequest(1, binding.Policy()))
298299 require.NoError(t, err)
299300 server.awaitAccepted(t, 2)
300301 require.Equal(t, 2, server.supervisor.Children())
@@ -307,14 +308,14 @@ func TestServerSupervisorServerLossIsolated(t *testing.T) {
307308 "the lost child was never reaped")
308309
309310 // The surviving child still accepts and the aggregate never failed.
310- logicalB2, err := physicalB.OpenStream(context.Background(), muxOpenRequest(2, binding.Policy()))
311+ logicalB2, err := openTyped(physicalB, context.Background(), muxOpenRequest(2, binding.Policy()))
311312 require.NoError(t, err)
312313 require.NotNil(t, logicalB2)
313314 server.awaitAccepted(t, 3)
314315
315316 // The lost physical refuses a fresh stream while its published logical
316317 // stream reports the physical loss.
317- _, err = physicalA.OpenStream(context.Background(), muxOpenRequest(2, binding.Policy()))
318+ _, err = openTyped(physicalA, context.Background(), muxOpenRequest(2, binding.Policy()))
318319 require.Error(t, err)
319320 require.True(t, channelClosed(logicalA.Done()))
320321 require.False(t, channelClosed(logicalB.Done()))
A internal/adapters/daemonmux/typed_stream_test.go +53 -0
@@ -0,0 +1,53 @@
1+package daemonmux
2+
3+import (
4+ "context"
5+ "sync"
6+
7+ "github.com/bnema/vev/internal/adapters/sessionwire"
8+ "github.com/bnema/vev/internal/ports"
9+)
10+
11+// typedStream adapts one raw mux stream to the typed session port the way the
12+// client side does, while keeping the raw stream's lifecycle observable.
13+type typedStream struct {
14+ ports.ClientConnection
15+ ports.BrokerEnvelopeStream
16+}
17+
18+var _ ports.BrokerLogicalConnection = typedStream{}
19+
20+func (s typedStream) Close() error { return s.ClientConnection.Close() }
21+
22+// typedViews keeps one session codec per raw stream: the codec owns the
23+// preamble, so a second codec on the same stream would restart it.
24+var typedViews sync.Map // ports.BrokerEnvelopeStream -> typedStream
25+
26+func asTyped(stream ports.BrokerEnvelopeStream) typedStream {
27+ if view, ok := typedViews.Load(stream); ok {
28+ return view.(typedStream)
29+ }
30+ view, _ := typedViews.LoadOrStore(stream, typedStream{ClientConnection: sessionwire.BrokerCodec{}.Client(stream), BrokerEnvelopeStream: stream})
31+ return view.(typedStream)
32+}
33+
34+// typedLogical is a typed view of one concrete logical connection.
35+type typedLogical struct {
36+ typedStream
37+ *LogicalConnection
38+}
39+
40+func (c typedLogical) Close() error { return c.typedStream.Close() }
41+
42+type envelopeOpener interface {
43+ OpenStream(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error)
44+}
45+
46+// openTyped opens one raw stream and returns its typed view; nil on failure.
47+func openTyped(opener envelopeOpener, ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
48+ stream, err := opener.OpenStream(ctx, request)
49+ if err != nil {
50+ return nil, err
51+ }
52+ return asTyped(stream), nil
53+}
M internal/adapters/daemonmux/unix_carriage_test.go +3 -3
@@ -148,10 +148,10 @@ func TestUnixCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) {
148148 require.NoError(t, server.awaitAdoption(t))
149149
150150 // Two independent typed admissions over the one physical carriage.
151- first, err := physical.OpenStream(context.Background(), muxOpenRequest(1, policy))
151+ first, err := openTyped(physical, context.Background(), muxOpenRequest(1, policy))
152152 require.NoError(t, err)
153153 t.Cleanup(func() { _ = first.Close() })
154- second, err := physical.OpenStream(context.Background(), muxOpenRequest(2, policy))
154+ second, err := openTyped(physical, context.Background(), muxOpenRequest(2, policy))
155155 require.NoError(t, err)
156156 t.Cleanup(func() { _ = second.Close() })
157157 server.awaitAccepted(t, 2)
@@ -172,7 +172,7 @@ func TestUnixCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) {
172172 wg.Add(1)
173173 go func(i int) {
174174 defer wg.Done()
175- connections[i], openErrs[i] = physical.OpenStream(context.Background(), muxOpenRequest(uint64(3+i), policy))
175+ connections[i], openErrs[i] = openTyped(physical, context.Background(), muxOpenRequest(uint64(3+i), policy))
176176 }(i)
177177 }
178178 wg.Wait()
A internal/adapters/sessionwire/broker_codec.go +43 -0
@@ -0,0 +1,43 @@
1+package sessionwire
2+
3+import (
4+ "io"
5+
6+ "github.com/bnema/vev/internal/ports"
7+ "github.com/bnema/vev/internal/protocol/wire"
8+)
9+
10+// BrokerCodec translates a raw broker envelope stream into the typed session
11+// protocol for the broker's own observation and preview operations.
12+// Attachment traffic stays opaque and never passes through this codec.
13+type BrokerCodec struct{}
14+
15+var _ ports.SessionCodec = BrokerCodec{}
16+
17+// Client returns the typed client view of stream, or nil for a nil stream.
18+func (BrokerCodec) Client(stream ports.BrokerEnvelopeStream) ports.ClientConnection {
19+ if stream == nil {
20+ return nil
21+ }
22+ return NewClientConnection(brokerEnvelopeTransport{stream: stream})
23+}
24+
25+// brokerEnvelopeTransport carries complete envelopes over a broker stream.
26+type brokerEnvelopeTransport struct{ stream ports.BrokerEnvelopeStream }
27+
28+var _ wire.Transport = brokerEnvelopeTransport{}
29+
30+func (t brokerEnvelopeTransport) Send(e wire.Envelope) error { return t.stream.SendEnvelope(e.Payload) }
31+
32+func (t brokerEnvelopeTransport) Recv() (wire.Envelope, error) {
33+ data, err := t.stream.RecvEnvelope()
34+ if err != nil {
35+ return wire.Envelope{}, err
36+ }
37+ if data == nil {
38+ return wire.Envelope{}, io.EOF
39+ }
40+ return wire.Envelope{Payload: data}, nil
41+}
42+
43+func (t brokerEnvelopeTransport) Close() error { return t.stream.Close() }
M internal/app/broker_offline.go +3 -2
@@ -21,6 +21,7 @@ import (
2121 "github.com/bnema/vev/internal/adapters/daemonmux"
2222 "github.com/bnema/vev/internal/adapters/ipc"
2323 "github.com/bnema/vev/internal/adapters/lifecycle"
24+ "github.com/bnema/vev/internal/adapters/sessionwire"
2425 "github.com/bnema/vev/internal/logging"
2526 "github.com/bnema/vev/internal/platform"
2627 "github.com/bnema/vev/internal/ports"
@@ -317,7 +318,7 @@ func runBrokerServe(ctx context.Context, options brokerServeOptions, deps broker
317318 if err != nil {
318319 return err
319320 }
320- remoteProbe := &brokerRemoteProbe{epoch: epoch, routes: resolver, connector: connector}
321+ remoteProbe := &brokerRemoteProbe{epoch: epoch, routes: resolver, connector: connector, codec: sessionwire.BrokerCodec{}}
321322 registry, err := broker.NewRegistryWithConfig(epoch, store, remoteProbe, clk, log, registryConfig)
322323 if err != nil {
323324 return err
@@ -345,7 +346,7 @@ func runBrokerServe(ctx context.Context, options brokerServeOptions, deps broker
345346 if err := supervisor.RegisterCloseable("pool", pool); err != nil {
346347 return err
347348 }
348- authority, err := broker.NewAuthority(epoch, registry, pool, supervisor)
349+ authority, err := broker.NewAuthority(epoch, registry, pool, supervisor, sessionwire.BrokerCodec{})
349350 if err != nil {
350351 return err
351352 }
M internal/app/broker_offline_local.go +5 -3
@@ -7,6 +7,7 @@ import (
77
88 "github.com/bnema/vev/internal/adapters/brokerconfig"
99 "github.com/bnema/vev/internal/adapters/daemonmux"
10+ "github.com/bnema/vev/internal/adapters/sessionwire"
1011 "github.com/bnema/vev/internal/domain"
1112 "github.com/bnema/vev/internal/ports"
1213 "github.com/bnema/vev/internal/usecase/broker"
@@ -60,6 +61,7 @@ type localRouteProbe struct {
6061 loadIdentity localIdentityLoader
6162 connector ports.BrokerEndpointConnector
6263 shared pooledPhysicals
64+ codec ports.SessionCodec
6365 }
6466
6567 var _ broker.LocalProbe = (*localRouteProbe)(nil)
@@ -87,7 +89,7 @@ func newDynamicLocalRouteProbe(route brokerconfig.Route, policy ports.BrokerPoli
8789 if err := policy.Validate(); err != nil {
8890 return nil, fmt.Errorf("vev: broker local probe: %w", err)
8991 }
90- return &localRouteProbe{epoch: epoch, route: route, policy: policy, loadIdentity: loadIdentity, connector: connector}, nil
92+ return &localRouteProbe{epoch: epoch, route: route, policy: policy, loadIdentity: loadIdentity, connector: connector, codec: sessionwire.BrokerCodec{}}, nil
9193 }
9294
9395 // ProbeLocal observes the local daemon by authenticating the daemonmux physical
@@ -127,7 +129,7 @@ func (p *localRouteProbe) ProbeLocal(ctx context.Context) (ports.BrokerDaemonObs
127129 if err != nil {
128130 return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, err
129131 }
130- if observation, handled, err := p.shared.observe(ctx, identity, p.policy, request); handled {
132+ if observation, handled, err := p.shared.observe(ctx, identity, p.policy, request, p.codec); handled {
131133 if err != nil {
132134 return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, err
133135 }
@@ -144,7 +146,7 @@ func (p *localRouteProbe) ProbeLocal(ctx context.Context) (ports.BrokerDaemonObs
144146 if physical.Identity() != endpoint.ExpectedIdentity.Identity || !physical.Policy().Compatible(endpoint.Policy) {
145147 return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, errors.New("vev: broker local probe authenticated binding mismatch")
146148 }
147- observation, err := observeDaemonCatalogue(ctx, physical, request)
149+ observation, err := observeDaemonCatalogue(ctx, physical, request, p.codec)
148150 if err != nil {
149151 return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, err
150152 }
M internal/app/broker_offline_local_attach_test.go +12 -2
@@ -18,6 +18,7 @@ import (
1818 "github.com/bnema/vev/internal/adapters/daemonmux"
1919 "github.com/bnema/vev/internal/adapters/ipc"
2020 "github.com/bnema/vev/internal/adapters/pty"
21+ "github.com/bnema/vev/internal/adapters/sessionwire"
2122 "github.com/bnema/vev/internal/domain"
2223 "github.com/bnema/vev/internal/ports"
2324 "github.com/bnema/vev/internal/protocol"
@@ -134,10 +135,19 @@ func (f *realLocalDaemonFixture) openStream(t *testing.T, request ports.BrokerOp
134135 }
135136 stream, err := physical.OpenStream(ctx, request)
136137 require.NoError(t, err)
137- t.Cleanup(func() { _ = stream.Close() })
138- return stream
138+ typed := brokerLogicalView{ClientConnection: sessionwire.BrokerCodec{}.Client(stream), BrokerEnvelopeStream: stream}
139+ t.Cleanup(func() { _ = typed.Close() })
140+ return typed
139141 }
140142
143+// brokerLogicalView is the typed client view of one raw logical stream.
144+type brokerLogicalView struct {
145+ ports.ClientConnection
146+ ports.BrokerEnvelopeStream
147+}
148+
149+func (v brokerLogicalView) Close() error { return v.ClientConnection.Close() }
150+
141151 // awaitWelcome receives server messages until the typed Welcome arrives.
142152 func awaitWelcome(t *testing.T, stream ports.BrokerLogicalConnection) protocol.Welcome {
143153 t.Helper()
M internal/app/broker_offline_test.go +4 -4
@@ -142,9 +142,9 @@ func awaitSandboxCancel(t *testing.T, cancel context.CancelFunc, done <-chan err
142142 // fixed terminal error, so a test can drive the accept drain without a carriage.
143143 type fatalListener struct{ err error }
144144
145-func (l fatalListener) Accept() (ports.BrokerService, error) { return nil, l.err }
146-func (l fatalListener) Close() error { return nil }
147-func (l fatalListener) Addr() string { return "fatal" }
145+func (l fatalListener) Accept() (ports.BrokerCoreService, error) { return nil, l.err }
146+func (l fatalListener) Close() error { return nil }
147+func (l fatalListener) Addr() string { return "fatal" }
148148
149149 // TestDrainBrokerAcceptClassifiesTerminalFailure proves the drain treats a
150150 // listener close as an orderly end with no log and no failure signal, while any
@@ -367,7 +367,7 @@ type wedgedListener struct {
367367 closed atomic.Bool
368368 }
369369
370-func (l *wedgedListener) Accept() (ports.BrokerService, error) { return nil, l.err }
370+func (l *wedgedListener) Accept() (ports.BrokerCoreService, error) { return nil, l.err }
371371 func (l *wedgedListener) Close() error {
372372 l.closed.Store(true)
373373 return nil
M internal/app/broker_remote_probe.go +11 -10
@@ -36,6 +36,7 @@ type brokerRemoteProbe struct {
3636 connector ports.BrokerEndpointConnector
3737 hosts ports.BrokerHostAuthorityReader
3838 shared pooledPhysicals
39+ codec ports.SessionCodec
3940 }
4041
4142 // sharedPhysicals lends the pooled transport of an attached or warm daemon.
@@ -60,7 +61,7 @@ func (s *pooledPhysicals) adopt(physical ports.BrokerPhysicalConnection, policy
6061 }
6162
6263 // observe reports handled=false when the probe must dial its own transport.
63-func (s *pooledPhysicals) observe(ctx context.Context, identity ports.BrokerDaemonIdentity, policy ports.BrokerPolicy, request ports.BrokerOpenStreamRequest) (ports.BrokerDaemonObservation, bool, error) {
64+func (s *pooledPhysicals) observe(ctx context.Context, identity ports.BrokerDaemonIdentity, policy ports.BrokerPolicy, request ports.BrokerOpenStreamRequest, codec ports.SessionCodec) (ports.BrokerDaemonObservation, bool, error) {
6465 pool, _ := s.pool.Load().(sharedPhysicals)
6566 if pool == nil || identity == "" {
6667 return ports.BrokerDaemonObservation{}, false, nil
@@ -69,7 +70,7 @@ func (s *pooledPhysicals) observe(ctx context.Context, identity ports.BrokerDaem
6970 if !ok {
7071 return ports.BrokerDaemonObservation{}, false, nil
7172 }
72- observation, err := observeDaemonCatalogue(ctx, physical, request)
73+ observation, err := observeDaemonCatalogue(ctx, physical, request, codec)
7374 if err == nil || ctx.Err() != nil {
7475 return observation, true, err
7576 }
@@ -99,7 +100,7 @@ func (p *brokerRemoteProbe) Probe(ctx context.Context, registration domain.Remot
99100 // bootstrapping SSH/QUIC again. A borrowed transport that retires mid-probe
100101 // falls back to a fresh dial.
101102 if endpoint.ExpectedIdentity.Bound {
102- if observation, handled, err := p.shared.observe(ctx, endpoint.ExpectedIdentity.Identity, endpoint.Policy, request); handled {
103+ if observation, handled, err := p.shared.observe(ctx, endpoint.ExpectedIdentity.Identity, endpoint.Policy, request, p.codec); handled {
103104 return observation, err
104105 }
105106 }
@@ -127,7 +128,7 @@ func (p *brokerRemoteProbe) Probe(ctx context.Context, registration domain.Remot
127128 if err != nil || identity != physical.Identity() {
128129 return ports.BrokerDaemonObservation{}, errors.New("vev: remote probe could not commit authenticated binding")
129130 }
130- observation, err := observeDaemonCatalogue(ctx, physical, request)
131+ observation, err := observeDaemonCatalogue(ctx, physical, request, p.codec)
131132 if err == nil && ctx.Err() == nil {
132133 adopted = p.shared.adopt(physical, endpoint.Policy)
133134 }
@@ -147,8 +148,8 @@ func (p *brokerRemoteProbe) Probe(ctx context.Context, registration domain.Remot
147148 // catalogue, and a catalogue outside the exact current schema all fail closed:
148149 // the caller receives an error and no observation it could publish, so a probe
149150 // never invents inventory it did not observe.
150-func observeDaemonCatalogue(ctx context.Context, physical ports.BrokerPhysicalConnection, request ports.BrokerOpenStreamRequest) (ports.BrokerDaemonObservation, error) {
151- if physical == nil || request.Purpose != ports.BrokerStreamObservation {
151+func observeDaemonCatalogue(ctx context.Context, physical ports.BrokerPhysicalConnection, request ports.BrokerOpenStreamRequest, codec ports.SessionCodec) (ports.BrokerDaemonObservation, error) {
152+ if physical == nil || codec == nil || request.Purpose != ports.BrokerStreamObservation {
152153 return ports.BrokerDaemonObservation{}, errors.New("vev: invalid daemon observation request")
153154 }
154155 logical, err := physical.OpenStream(ctx, request)
@@ -167,7 +168,7 @@ func observeDaemonCatalogue(ctx context.Context, physical ports.BrokerPhysicalCo
167168 if err != nil {
168169 return ports.BrokerDaemonObservation{}, err
169170 }
170- reply, err := exchangeObservationCommand(ctx, logical, protocol.CommandRequest{RequestID: commandID, Version: protocol.Version, Slug: "remote-catalog", JSON: true})
171+ reply, err := exchangeObservationCommand(ctx, codec.Client(logical), logical, protocol.CommandRequest{RequestID: commandID, Version: protocol.Version, Slug: "remote-catalog", JSON: true})
171172 if err != nil {
172173 return ports.BrokerDaemonObservation{}, err
173174 }
@@ -201,7 +202,7 @@ func observeDaemonCatalogue(ctx context.Context, physical ports.BrokerPhysicalCo
201202 // joined before returning, so an observation always returns promptly once its
202203 // attempt is retired instead of parking the daemon's reader (or a probe
203204 // attempt) on a daemon that answers nothing.
204-func exchangeObservationCommand(ctx context.Context, logical ports.BrokerLogicalConnection, command protocol.CommandRequest) (protocol.ServerMessage, error) {
205+func exchangeObservationCommand(ctx context.Context, typed ports.ClientConnection, logical ports.BrokerEnvelopeStream, command protocol.CommandRequest) (protocol.ServerMessage, error) {
205206 if ctx == nil {
206207 ctx = context.Background()
207208 }
@@ -211,11 +212,11 @@ func exchangeObservationCommand(ctx context.Context, logical ports.BrokerLogical
211212 }
212213 done := make(chan outcome, 1)
213214 go func() {
214- if err := logical.SendClient(command); err != nil {
215+ if err := typed.SendClient(command); err != nil {
215216 done <- outcome{err: err}
216217 return
217218 }
218- message, err := logical.ReceiveServer()
219+ message, err := typed.ReceiveServer()
219220 done <- outcome{message: message, err: err}
220221 }()
221222 select {
M internal/app/broker_remote_probe_shared_test.go +15 -9
@@ -56,6 +56,7 @@ func TestBrokerRemoteProbeBorrowsWarmTransport(t *testing.T) {
5656 connector.EXPECT().Connect(mock.Anything, mock.Anything).Return(nil, dialErr).Times(tt.wantDials)
5757 }
5858 physical := portsmocks.NewMockBrokerPhysicalConnection(t)
59+ codec := portsmocks.NewMockSessionCodec(t)
5960 done := make(chan struct{})
6061 if tt.retired {
6162 close(done)
@@ -67,13 +68,15 @@ func TestBrokerRemoteProbeBorrowsWarmTransport(t *testing.T) {
6768 physical.EXPECT().Done().Return(done)
6869 }
6970 } else {
70- logical := portsmocks.NewMockBrokerLogicalConnection(t)
71+ logical := portsmocks.NewMockBrokerEnvelopeStream(t)
72+ typed := portsmocks.NewMockClientConnection(t)
73+ codec.EXPECT().Client(logical).Return(typed)
7174 var sent protocol.CommandRequest
72- logical.EXPECT().SendClient(mock.Anything).RunAndReturn(func(message protocol.ClientMessage) error {
75+ typed.EXPECT().SendClient(mock.Anything).RunAndReturn(func(message protocol.ClientMessage) error {
7376 sent = message.(protocol.CommandRequest)
7477 return nil
7578 })
76- logical.EXPECT().ReceiveServer().RunAndReturn(func() (protocol.ServerMessage, error) {
79+ typed.EXPECT().ReceiveServer().RunAndReturn(func() (protocol.ServerMessage, error) {
7780 return protocol.CommandResult{RequestID: sent.RequestID, Outcome: protocol.CommandSucceeded, Output: testLocalCatalogue(t)}, nil
7881 })
7982 logical.EXPECT().Close().Return(nil)
@@ -84,7 +87,7 @@ func TestBrokerRemoteProbeBorrowsWarmTransport(t *testing.T) {
8487 }
8588 probe := &brokerRemoteProbe{
8689 epoch: 7, routes: routes, binder: portsmocks.NewMockBrokerIdentityBinder(t), connector: connector,
87- hosts: &routeTestHosts{record: record, found: true},
90+ hosts: &routeTestHosts{record: record, found: true}, codec: codec,
8891 }
8992 // Use the real pool for borrowing. Stateful pool retirement is
9093 // covered with a fake physical in broker's worker tests.
@@ -145,6 +148,7 @@ func TestBrokerRemoteProbeSilentBorrowedTransportNeverRedials(t *testing.T) {
145148 // No Connect expectation: any redial fails the mock.
146149 connector := portsmocks.NewMockBrokerEndpointConnector(t)
147150 physical := portsmocks.NewMockBrokerPhysicalConnection(t)
151+ codec := portsmocks.NewMockSessionCodec(t)
148152 healthy := make(chan struct{})
149153 physical.EXPECT().Policy().Return(policy).Maybe()
150154 physical.EXPECT().Identity().Return(identity).Maybe()
@@ -158,17 +162,19 @@ func TestBrokerRemoteProbeSilentBorrowedTransportNeverRedials(t *testing.T) {
158162 // worker only signals, the test goroutine cancels and asserts.
159163 waiting := make(chan struct{}, 1)
160164 if tt.silentOpen {
161- physical.EXPECT().OpenStream(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, _ ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
165+ physical.EXPECT().OpenStream(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, _ ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
162166 waiting <- struct{}{}
163167 <-ctx.Done()
164168 return nil, ctx.Err()
165169 })
166170 } else {
167- logical := portsmocks.NewMockBrokerLogicalConnection(t)
171+ logical := portsmocks.NewMockBrokerEnvelopeStream(t)
172+ typed := portsmocks.NewMockClientConnection(t)
173+ codec.EXPECT().Client(logical).Return(typed)
168174 closed := make(chan struct{})
169175 var once sync.Once
170- logical.EXPECT().SendClient(mock.Anything).Return(nil)
171- logical.EXPECT().ReceiveServer().RunAndReturn(func() (protocol.ServerMessage, error) {
176+ typed.EXPECT().SendClient(mock.Anything).Return(nil)
177+ typed.EXPECT().ReceiveServer().RunAndReturn(func() (protocol.ServerMessage, error) {
172178 waiting <- struct{}{}
173179 <-closed
174180 return nil, errors.New("stream closed")
@@ -178,7 +184,7 @@ func TestBrokerRemoteProbeSilentBorrowedTransportNeverRedials(t *testing.T) {
178184 }
179185 probe := &brokerRemoteProbe{
180186 epoch: 7, routes: routes, binder: portsmocks.NewMockBrokerIdentityBinder(t), connector: connector,
181- hosts: &routeTestHosts{record: record, found: true},
187+ hosts: &routeTestHosts{record: record, found: true}, codec: codec,
182188 }
183189 pool, err := broker.NewPool(7, routes, probe.binder, connector, clock.New(), broker.PoolLimits{Physical: 1, Clients: 1, Streams: 2, StreamsPerClient: 2, Warm: 1})
184190 require.NoError(t, err)
M internal/ports/broker.go +30 -5
@@ -823,7 +823,7 @@ type BrokerPreviewSubscription interface {
823823 // local and remote daemons through it, including the local daemon.
824824 // Snapshot access performs no I/O; request methods are non-blocking
825825 // coalesced hints except where the context explicitly bounds them.
826-type BrokerService interface {
826+type BrokerSession interface {
827827 // ConnectionID returns the ID assigned when this client connection was
828828 // accepted. Clients carry it on stream operations to fence stale requests.
829829 ConnectionID() BrokerConnectionID
@@ -844,7 +844,6 @@ type BrokerService interface {
844844 Snapshot() BrokerSnapshot
845845 Subscribe() (BrokerSubscription, error)
846846 SubscribePreview(request BrokerPreviewRequest) (BrokerPreviewSubscription, error)
847- OpenStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerLogicalConnection, error)
848847 CloseStream(connection BrokerConnectionID, stream BrokerStreamID) error
849848 // AddHost durably adds or pins endpoint under policy and returns its authority.
850849 AddHost(ctx context.Context, endpoint string, policy BrokerPolicy) (domain.RemoteRegistration, error)
@@ -856,6 +855,32 @@ type BrokerService interface {
856855 Close() error
857856 }
858857
858+// BrokerService is the typed client-side broker connection.
859+type BrokerService interface {
860+ BrokerSession
861+ OpenStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerLogicalConnection, error)
862+}
863+
864+// BrokerEnvelopeStream carries opaque complete session envelopes across the core.
865+type BrokerEnvelopeStream interface {
866+ SendEnvelope([]byte) error
867+ RecvEnvelope() ([]byte, error)
868+ Done() <-chan struct{}
869+ Err() error
870+ Close() error
871+}
872+
873+// BrokerCoreService is one admitted connection on the broker side.
874+type BrokerCoreService interface {
875+ BrokerSession
876+ OpenEnvelopeStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerEnvelopeStream, error)
877+}
878+
879+// SessionCodec adapts a raw core stream for broker-owned typed operations.
880+type SessionCodec interface {
881+ Client(BrokerEnvelopeStream) ClientConnection
882+}
883+
859884 // BrokerSnapshotStore persists the durable broker snapshot independently
860885 // from session state. The broker is its sole writer; session persistence
861886 // stays daemon-owned and is never moved here. Load is called once while the
@@ -910,7 +935,7 @@ type BrokerPhysicalConnection interface {
910935 Identity() BrokerDaemonIdentity
911936 Incarnation() BrokerDaemonIncarnation
912937 Policy() BrokerPolicy
913- OpenStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerLogicalConnection, error)
938+ OpenStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerEnvelopeStream, error)
914939 Close() error
915940 }
916941
@@ -961,7 +986,7 @@ type BrokerConnector interface {
961986 // parked in admission immediately. The admitted service gets its own
962987 // connection-lived context and must not derive from this one.
963988 type BrokerAuthority interface {
964- AdmitClient(ctx context.Context) (BrokerService, error)
989+ AdmitClient(ctx context.Context) (BrokerCoreService, error)
965990 }
966991
967992 // BrokerListener accepts client connections to the per-user broker
@@ -972,7 +997,7 @@ type BrokerAuthority interface {
972997 // Implementations own the owner-only directory/socket, peer credential
973998 // checks, bounded clients and queues, and cancellation-safe accept loops.
974999 type BrokerListener interface {
975- Accept() (BrokerService, error)
1000+ Accept() (BrokerCoreService, error)
9761001 Close() error
9771002 Addr() string
9781003 }
M internal/ports/mocks/broker_mock.go +2036 -165
@@ -268,13 +268,1804 @@ func (_c *MockBrokerPreviewSubscription_Latest_Call) RunAndReturn(run func() por
268268 return _c
269269 }
270270
271+// NewMockBrokerSession creates a new instance of MockBrokerSession. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
272+// The first argument is typically a *testing.T value.
273+func NewMockBrokerSession(t interface {
274+ mock.TestingT
275+ Cleanup(func())
276+}) *MockBrokerSession {
277+ mock := &MockBrokerSession{}
278+ mock.Mock.Test(t)
279+
280+ t.Cleanup(func() { mock.AssertExpectations(t) })
281+
282+ return mock
283+}
284+
285+// MockBrokerSession is an autogenerated mock type for the BrokerSession type
286+type MockBrokerSession struct {
287+ mock.Mock
288+}
289+
290+type MockBrokerSession_Expecter struct {
291+ mock *mock.Mock
292+}
293+
294+func (_m *MockBrokerSession) EXPECT() *MockBrokerSession_Expecter {
295+ return &MockBrokerSession_Expecter{mock: &_m.Mock}
296+}
297+
298+// AddHost provides a mock function for the type MockBrokerSession
299+func (_mock *MockBrokerSession) AddHost(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
300+ ret := _mock.Called(ctx, endpoint, policy)
301+
302+ if len(ret) == 0 {
303+ panic("no return value specified for AddHost")
304+ }
305+
306+ var r0 domain.RemoteRegistration
307+ var r1 error
308+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, ports.BrokerPolicy) (domain.RemoteRegistration, error)); ok {
309+ return returnFunc(ctx, endpoint, policy)
310+ }
311+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, ports.BrokerPolicy) domain.RemoteRegistration); ok {
312+ r0 = returnFunc(ctx, endpoint, policy)
313+ } else {
314+ r0 = ret.Get(0).(domain.RemoteRegistration)
315+ }
316+ if returnFunc, ok := ret.Get(1).(func(context.Context, string, ports.BrokerPolicy) error); ok {
317+ r1 = returnFunc(ctx, endpoint, policy)
318+ } else {
319+ r1 = ret.Error(1)
320+ }
321+ return r0, r1
322+}
323+
324+// MockBrokerSession_AddHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddHost'
325+type MockBrokerSession_AddHost_Call struct {
326+ *mock.Call
327+}
328+
329+// AddHost is a helper method to define mock.On call
330+// - ctx context.Context
331+// - endpoint string
332+// - policy ports.BrokerPolicy
333+func (_e *MockBrokerSession_Expecter) AddHost(ctx any, endpoint any, policy any) *MockBrokerSession_AddHost_Call {
334+ return &MockBrokerSession_AddHost_Call{Call: _e.mock.On("AddHost", ctx, endpoint, policy)}
335+}
336+
337+func (_c *MockBrokerSession_AddHost_Call) Run(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy)) *MockBrokerSession_AddHost_Call {
338+ _c.Call.Run(func(args mock.Arguments) {
339+ var arg0 context.Context
340+ if args[0] != nil {
341+ arg0 = args[0].(context.Context)
342+ }
343+ var arg1 string
344+ if args[1] != nil {
345+ arg1 = args[1].(string)
346+ }
347+ var arg2 ports.BrokerPolicy
348+ if args[2] != nil {
349+ arg2 = args[2].(ports.BrokerPolicy)
350+ }
351+ run(
352+ arg0,
353+ arg1,
354+ arg2,
355+ )
356+ })
357+ return _c
358+}
359+
360+func (_c *MockBrokerSession_AddHost_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerSession_AddHost_Call {
361+ _c.Call.Return(remoteRegistration, err)
362+ return _c
363+}
364+
365+func (_c *MockBrokerSession_AddHost_Call) RunAndReturn(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerSession_AddHost_Call {
366+ _c.Call.Return(run)
367+ return _c
368+}
369+
370+// Close provides a mock function for the type MockBrokerSession
371+func (_mock *MockBrokerSession) Close() error {
372+ ret := _mock.Called()
373+
374+ if len(ret) == 0 {
375+ panic("no return value specified for Close")
376+ }
377+
378+ var r0 error
379+ if returnFunc, ok := ret.Get(0).(func() error); ok {
380+ r0 = returnFunc()
381+ } else {
382+ r0 = ret.Error(0)
383+ }
384+ return r0
385+}
386+
387+// MockBrokerSession_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
388+type MockBrokerSession_Close_Call struct {
389+ *mock.Call
390+}
391+
392+// Close is a helper method to define mock.On call
393+func (_e *MockBrokerSession_Expecter) Close() *MockBrokerSession_Close_Call {
394+ return &MockBrokerSession_Close_Call{Call: _e.mock.On("Close")}
395+}
396+
397+func (_c *MockBrokerSession_Close_Call) Run(run func()) *MockBrokerSession_Close_Call {
398+ _c.Call.Run(func(args mock.Arguments) {
399+ run()
400+ })
401+ return _c
402+}
403+
404+func (_c *MockBrokerSession_Close_Call) Return(err error) *MockBrokerSession_Close_Call {
405+ _c.Call.Return(err)
406+ return _c
407+}
408+
409+func (_c *MockBrokerSession_Close_Call) RunAndReturn(run func() error) *MockBrokerSession_Close_Call {
410+ _c.Call.Return(run)
411+ return _c
412+}
413+
414+// CloseStream provides a mock function for the type MockBrokerSession
415+func (_mock *MockBrokerSession) CloseStream(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error {
416+ ret := _mock.Called(connection, stream)
417+
418+ if len(ret) == 0 {
419+ panic("no return value specified for CloseStream")
420+ }
421+
422+ var r0 error
423+ if returnFunc, ok := ret.Get(0).(func(ports.BrokerConnectionID, ports.BrokerStreamID) error); ok {
424+ r0 = returnFunc(connection, stream)
425+ } else {
426+ r0 = ret.Error(0)
427+ }
428+ return r0
429+}
430+
431+// MockBrokerSession_CloseStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CloseStream'
432+type MockBrokerSession_CloseStream_Call struct {
433+ *mock.Call
434+}
435+
436+// CloseStream is a helper method to define mock.On call
437+// - connection ports.BrokerConnectionID
438+// - stream ports.BrokerStreamID
439+func (_e *MockBrokerSession_Expecter) CloseStream(connection any, stream any) *MockBrokerSession_CloseStream_Call {
440+ return &MockBrokerSession_CloseStream_Call{Call: _e.mock.On("CloseStream", connection, stream)}
441+}
442+
443+func (_c *MockBrokerSession_CloseStream_Call) Run(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID)) *MockBrokerSession_CloseStream_Call {
444+ _c.Call.Run(func(args mock.Arguments) {
445+ var arg0 ports.BrokerConnectionID
446+ if args[0] != nil {
447+ arg0 = args[0].(ports.BrokerConnectionID)
448+ }
449+ var arg1 ports.BrokerStreamID
450+ if args[1] != nil {
451+ arg1 = args[1].(ports.BrokerStreamID)
452+ }
453+ run(
454+ arg0,
455+ arg1,
456+ )
457+ })
458+ return _c
459+}
460+
461+func (_c *MockBrokerSession_CloseStream_Call) Return(err error) *MockBrokerSession_CloseStream_Call {
462+ _c.Call.Return(err)
463+ return _c
464+}
465+
466+func (_c *MockBrokerSession_CloseStream_Call) RunAndReturn(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error) *MockBrokerSession_CloseStream_Call {
467+ _c.Call.Return(run)
468+ return _c
469+}
470+
471+// ConnectionID provides a mock function for the type MockBrokerSession
472+func (_mock *MockBrokerSession) ConnectionID() ports.BrokerConnectionID {
473+ ret := _mock.Called()
474+
475+ if len(ret) == 0 {
476+ panic("no return value specified for ConnectionID")
477+ }
478+
479+ var r0 ports.BrokerConnectionID
480+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerConnectionID); ok {
481+ r0 = returnFunc()
482+ } else {
483+ if ret.Get(0) != nil {
484+ r0 = ret.Get(0).(ports.BrokerConnectionID)
485+ }
486+ }
487+ return r0
488+}
489+
490+// MockBrokerSession_ConnectionID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConnectionID'
491+type MockBrokerSession_ConnectionID_Call struct {
492+ *mock.Call
493+}
494+
495+// ConnectionID is a helper method to define mock.On call
496+func (_e *MockBrokerSession_Expecter) ConnectionID() *MockBrokerSession_ConnectionID_Call {
497+ return &MockBrokerSession_ConnectionID_Call{Call: _e.mock.On("ConnectionID")}
498+}
499+
500+func (_c *MockBrokerSession_ConnectionID_Call) Run(run func()) *MockBrokerSession_ConnectionID_Call {
501+ _c.Call.Run(func(args mock.Arguments) {
502+ run()
503+ })
504+ return _c
505+}
506+
507+func (_c *MockBrokerSession_ConnectionID_Call) Return(brokerConnectionID ports.BrokerConnectionID) *MockBrokerSession_ConnectionID_Call {
508+ _c.Call.Return(brokerConnectionID)
509+ return _c
510+}
511+
512+func (_c *MockBrokerSession_ConnectionID_Call) RunAndReturn(run func() ports.BrokerConnectionID) *MockBrokerSession_ConnectionID_Call {
513+ _c.Call.Return(run)
514+ return _c
515+}
516+
517+// Done provides a mock function for the type MockBrokerSession
518+func (_mock *MockBrokerSession) Done() <-chan struct{} {
519+ ret := _mock.Called()
520+
521+ if len(ret) == 0 {
522+ panic("no return value specified for Done")
523+ }
524+
525+ var r0 <-chan struct{}
526+ if returnFunc, ok := ret.Get(0).(func() <-chan struct{}); ok {
527+ r0 = returnFunc()
528+ } else {
529+ if ret.Get(0) != nil {
530+ r0 = ret.Get(0).(<-chan struct{})
531+ }
532+ }
533+ return r0
534+}
535+
536+// MockBrokerSession_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done'
537+type MockBrokerSession_Done_Call struct {
538+ *mock.Call
539+}
540+
541+// Done is a helper method to define mock.On call
542+func (_e *MockBrokerSession_Expecter) Done() *MockBrokerSession_Done_Call {
543+ return &MockBrokerSession_Done_Call{Call: _e.mock.On("Done")}
544+}
545+
546+func (_c *MockBrokerSession_Done_Call) Run(run func()) *MockBrokerSession_Done_Call {
547+ _c.Call.Run(func(args mock.Arguments) {
548+ run()
549+ })
550+ return _c
551+}
552+
553+func (_c *MockBrokerSession_Done_Call) Return(valCh <-chan struct{}) *MockBrokerSession_Done_Call {
554+ _c.Call.Return(valCh)
555+ return _c
556+}
557+
558+func (_c *MockBrokerSession_Done_Call) RunAndReturn(run func() <-chan struct{}) *MockBrokerSession_Done_Call {
559+ _c.Call.Return(run)
560+ return _c
561+}
562+
563+// Err provides a mock function for the type MockBrokerSession
564+func (_mock *MockBrokerSession) Err() error {
565+ ret := _mock.Called()
566+
567+ if len(ret) == 0 {
568+ panic("no return value specified for Err")
569+ }
570+
571+ var r0 error
572+ if returnFunc, ok := ret.Get(0).(func() error); ok {
573+ r0 = returnFunc()
574+ } else {
575+ r0 = ret.Error(0)
576+ }
577+ return r0
578+}
579+
580+// MockBrokerSession_Err_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Err'
581+type MockBrokerSession_Err_Call struct {
582+ *mock.Call
583+}
584+
585+// Err is a helper method to define mock.On call
586+func (_e *MockBrokerSession_Expecter) Err() *MockBrokerSession_Err_Call {
587+ return &MockBrokerSession_Err_Call{Call: _e.mock.On("Err")}
588+}
589+
590+func (_c *MockBrokerSession_Err_Call) Run(run func()) *MockBrokerSession_Err_Call {
591+ _c.Call.Run(func(args mock.Arguments) {
592+ run()
593+ })
594+ return _c
595+}
596+
597+func (_c *MockBrokerSession_Err_Call) Return(err error) *MockBrokerSession_Err_Call {
598+ _c.Call.Return(err)
599+ return _c
600+}
601+
602+func (_c *MockBrokerSession_Err_Call) RunAndReturn(run func() error) *MockBrokerSession_Err_Call {
603+ _c.Call.Return(run)
604+ return _c
605+}
606+
607+// NextStreamID provides a mock function for the type MockBrokerSession
608+func (_mock *MockBrokerSession) NextStreamID() (ports.BrokerStreamID, error) {
609+ ret := _mock.Called()
610+
611+ if len(ret) == 0 {
612+ panic("no return value specified for NextStreamID")
613+ }
614+
615+ var r0 ports.BrokerStreamID
616+ var r1 error
617+ if returnFunc, ok := ret.Get(0).(func() (ports.BrokerStreamID, error)); ok {
618+ return returnFunc()
619+ }
620+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerStreamID); ok {
621+ r0 = returnFunc()
622+ } else {
623+ r0 = ret.Get(0).(ports.BrokerStreamID)
624+ }
625+ if returnFunc, ok := ret.Get(1).(func() error); ok {
626+ r1 = returnFunc()
627+ } else {
628+ r1 = ret.Error(1)
629+ }
630+ return r0, r1
631+}
632+
633+// MockBrokerSession_NextStreamID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextStreamID'
634+type MockBrokerSession_NextStreamID_Call struct {
635+ *mock.Call
636+}
637+
638+// NextStreamID is a helper method to define mock.On call
639+func (_e *MockBrokerSession_Expecter) NextStreamID() *MockBrokerSession_NextStreamID_Call {
640+ return &MockBrokerSession_NextStreamID_Call{Call: _e.mock.On("NextStreamID")}
641+}
642+
643+func (_c *MockBrokerSession_NextStreamID_Call) Run(run func()) *MockBrokerSession_NextStreamID_Call {
644+ _c.Call.Run(func(args mock.Arguments) {
645+ run()
646+ })
647+ return _c
648+}
649+
650+func (_c *MockBrokerSession_NextStreamID_Call) Return(brokerStreamID ports.BrokerStreamID, err error) *MockBrokerSession_NextStreamID_Call {
651+ _c.Call.Return(brokerStreamID, err)
652+ return _c
653+}
654+
655+func (_c *MockBrokerSession_NextStreamID_Call) RunAndReturn(run func() (ports.BrokerStreamID, error)) *MockBrokerSession_NextStreamID_Call {
656+ _c.Call.Return(run)
657+ return _c
658+}
659+
660+// RemoveHost provides a mock function for the type MockBrokerSession
661+func (_mock *MockBrokerSession) RemoveHost(ctx context.Context, expected domain.RemoteRegistration) (bool, error) {
662+ ret := _mock.Called(ctx, expected)
663+
664+ if len(ret) == 0 {
665+ panic("no return value specified for RemoveHost")
666+ }
667+
668+ var r0 bool
669+ var r1 error
670+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration) (bool, error)); ok {
671+ return returnFunc(ctx, expected)
672+ }
673+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration) bool); ok {
674+ r0 = returnFunc(ctx, expected)
675+ } else {
676+ r0 = ret.Get(0).(bool)
677+ }
678+ if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RemoteRegistration) error); ok {
679+ r1 = returnFunc(ctx, expected)
680+ } else {
681+ r1 = ret.Error(1)
682+ }
683+ return r0, r1
684+}
685+
686+// MockBrokerSession_RemoveHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveHost'
687+type MockBrokerSession_RemoveHost_Call struct {
688+ *mock.Call
689+}
690+
691+// RemoveHost is a helper method to define mock.On call
692+// - ctx context.Context
693+// - expected domain.RemoteRegistration
694+func (_e *MockBrokerSession_Expecter) RemoveHost(ctx any, expected any) *MockBrokerSession_RemoveHost_Call {
695+ return &MockBrokerSession_RemoveHost_Call{Call: _e.mock.On("RemoveHost", ctx, expected)}
696+}
697+
698+func (_c *MockBrokerSession_RemoveHost_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration)) *MockBrokerSession_RemoveHost_Call {
699+ _c.Call.Run(func(args mock.Arguments) {
700+ var arg0 context.Context
701+ if args[0] != nil {
702+ arg0 = args[0].(context.Context)
703+ }
704+ var arg1 domain.RemoteRegistration
705+ if args[1] != nil {
706+ arg1 = args[1].(domain.RemoteRegistration)
707+ }
708+ run(
709+ arg0,
710+ arg1,
711+ )
712+ })
713+ return _c
714+}
715+
716+func (_c *MockBrokerSession_RemoveHost_Call) Return(b bool, err error) *MockBrokerSession_RemoveHost_Call {
717+ _c.Call.Return(b, err)
718+ return _c
719+}
720+
721+func (_c *MockBrokerSession_RemoveHost_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration) (bool, error)) *MockBrokerSession_RemoveHost_Call {
722+ _c.Call.Return(run)
723+ return _c
724+}
725+
726+// RequestReconcile provides a mock function for the type MockBrokerSession
727+func (_mock *MockBrokerSession) RequestReconcile(endpoint string) {
728+ _mock.Called(endpoint)
729+ return
730+}
731+
732+// MockBrokerSession_RequestReconcile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestReconcile'
733+type MockBrokerSession_RequestReconcile_Call struct {
734+ *mock.Call
735+}
736+
737+// RequestReconcile is a helper method to define mock.On call
738+// - endpoint string
739+func (_e *MockBrokerSession_Expecter) RequestReconcile(endpoint any) *MockBrokerSession_RequestReconcile_Call {
740+ return &MockBrokerSession_RequestReconcile_Call{Call: _e.mock.On("RequestReconcile", endpoint)}
741+}
742+
743+func (_c *MockBrokerSession_RequestReconcile_Call) Run(run func(endpoint string)) *MockBrokerSession_RequestReconcile_Call {
744+ _c.Call.Run(func(args mock.Arguments) {
745+ var arg0 string
746+ if args[0] != nil {
747+ arg0 = args[0].(string)
748+ }
749+ run(
750+ arg0,
751+ )
752+ })
753+ return _c
754+}
755+
756+func (_c *MockBrokerSession_RequestReconcile_Call) Return() *MockBrokerSession_RequestReconcile_Call {
757+ _c.Call.Return()
758+ return _c
759+}
760+
761+func (_c *MockBrokerSession_RequestReconcile_Call) RunAndReturn(run func(endpoint string)) *MockBrokerSession_RequestReconcile_Call {
762+ _c.Run(run)
763+ return _c
764+}
765+
766+// Snapshot provides a mock function for the type MockBrokerSession
767+func (_mock *MockBrokerSession) Snapshot() ports.BrokerSnapshot {
768+ ret := _mock.Called()
769+
770+ if len(ret) == 0 {
771+ panic("no return value specified for Snapshot")
772+ }
773+
774+ var r0 ports.BrokerSnapshot
775+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerSnapshot); ok {
776+ r0 = returnFunc()
777+ } else {
778+ r0 = ret.Get(0).(ports.BrokerSnapshot)
779+ }
780+ return r0
781+}
782+
783+// MockBrokerSession_Snapshot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Snapshot'
784+type MockBrokerSession_Snapshot_Call struct {
785+ *mock.Call
786+}
787+
788+// Snapshot is a helper method to define mock.On call
789+func (_e *MockBrokerSession_Expecter) Snapshot() *MockBrokerSession_Snapshot_Call {
790+ return &MockBrokerSession_Snapshot_Call{Call: _e.mock.On("Snapshot")}
791+}
792+
793+func (_c *MockBrokerSession_Snapshot_Call) Run(run func()) *MockBrokerSession_Snapshot_Call {
794+ _c.Call.Run(func(args mock.Arguments) {
795+ run()
796+ })
797+ return _c
798+}
799+
800+func (_c *MockBrokerSession_Snapshot_Call) Return(brokerSnapshot ports.BrokerSnapshot) *MockBrokerSession_Snapshot_Call {
801+ _c.Call.Return(brokerSnapshot)
802+ return _c
803+}
804+
805+func (_c *MockBrokerSession_Snapshot_Call) RunAndReturn(run func() ports.BrokerSnapshot) *MockBrokerSession_Snapshot_Call {
806+ _c.Call.Return(run)
807+ return _c
808+}
809+
810+// Subscribe provides a mock function for the type MockBrokerSession
811+func (_mock *MockBrokerSession) Subscribe() (ports.BrokerSubscription, error) {
812+ ret := _mock.Called()
813+
814+ if len(ret) == 0 {
815+ panic("no return value specified for Subscribe")
816+ }
817+
818+ var r0 ports.BrokerSubscription
819+ var r1 error
820+ if returnFunc, ok := ret.Get(0).(func() (ports.BrokerSubscription, error)); ok {
821+ return returnFunc()
822+ }
823+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerSubscription); ok {
824+ r0 = returnFunc()
825+ } else {
826+ if ret.Get(0) != nil {
827+ r0 = ret.Get(0).(ports.BrokerSubscription)
828+ }
829+ }
830+ if returnFunc, ok := ret.Get(1).(func() error); ok {
831+ r1 = returnFunc()
832+ } else {
833+ r1 = ret.Error(1)
834+ }
835+ return r0, r1
836+}
837+
838+// MockBrokerSession_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe'
839+type MockBrokerSession_Subscribe_Call struct {
840+ *mock.Call
841+}
842+
843+// Subscribe is a helper method to define mock.On call
844+func (_e *MockBrokerSession_Expecter) Subscribe() *MockBrokerSession_Subscribe_Call {
845+ return &MockBrokerSession_Subscribe_Call{Call: _e.mock.On("Subscribe")}
846+}
847+
848+func (_c *MockBrokerSession_Subscribe_Call) Run(run func()) *MockBrokerSession_Subscribe_Call {
849+ _c.Call.Run(func(args mock.Arguments) {
850+ run()
851+ })
852+ return _c
853+}
854+
855+func (_c *MockBrokerSession_Subscribe_Call) Return(brokerSubscription ports.BrokerSubscription, err error) *MockBrokerSession_Subscribe_Call {
856+ _c.Call.Return(brokerSubscription, err)
857+ return _c
858+}
859+
860+func (_c *MockBrokerSession_Subscribe_Call) RunAndReturn(run func() (ports.BrokerSubscription, error)) *MockBrokerSession_Subscribe_Call {
861+ _c.Call.Return(run)
862+ return _c
863+}
864+
865+// SubscribePreview provides a mock function for the type MockBrokerSession
866+func (_mock *MockBrokerSession) SubscribePreview(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error) {
867+ ret := _mock.Called(request)
868+
869+ if len(ret) == 0 {
870+ panic("no return value specified for SubscribePreview")
871+ }
872+
873+ var r0 ports.BrokerPreviewSubscription
874+ var r1 error
875+ if returnFunc, ok := ret.Get(0).(func(ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error)); ok {
876+ return returnFunc(request)
877+ }
878+ if returnFunc, ok := ret.Get(0).(func(ports.BrokerPreviewRequest) ports.BrokerPreviewSubscription); ok {
879+ r0 = returnFunc(request)
880+ } else {
881+ if ret.Get(0) != nil {
882+ r0 = ret.Get(0).(ports.BrokerPreviewSubscription)
883+ }
884+ }
885+ if returnFunc, ok := ret.Get(1).(func(ports.BrokerPreviewRequest) error); ok {
886+ r1 = returnFunc(request)
887+ } else {
888+ r1 = ret.Error(1)
889+ }
890+ return r0, r1
891+}
892+
893+// MockBrokerSession_SubscribePreview_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribePreview'
894+type MockBrokerSession_SubscribePreview_Call struct {
895+ *mock.Call
896+}
897+
898+// SubscribePreview is a helper method to define mock.On call
899+// - request ports.BrokerPreviewRequest
900+func (_e *MockBrokerSession_Expecter) SubscribePreview(request any) *MockBrokerSession_SubscribePreview_Call {
901+ return &MockBrokerSession_SubscribePreview_Call{Call: _e.mock.On("SubscribePreview", request)}
902+}
903+
904+func (_c *MockBrokerSession_SubscribePreview_Call) Run(run func(request ports.BrokerPreviewRequest)) *MockBrokerSession_SubscribePreview_Call {
905+ _c.Call.Run(func(args mock.Arguments) {
906+ var arg0 ports.BrokerPreviewRequest
907+ if args[0] != nil {
908+ arg0 = args[0].(ports.BrokerPreviewRequest)
909+ }
910+ run(
911+ arg0,
912+ )
913+ })
914+ return _c
915+}
916+
917+func (_c *MockBrokerSession_SubscribePreview_Call) Return(brokerPreviewSubscription ports.BrokerPreviewSubscription, err error) *MockBrokerSession_SubscribePreview_Call {
918+ _c.Call.Return(brokerPreviewSubscription, err)
919+ return _c
920+}
921+
922+func (_c *MockBrokerSession_SubscribePreview_Call) RunAndReturn(run func(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error)) *MockBrokerSession_SubscribePreview_Call {
923+ _c.Call.Return(run)
924+ return _c
925+}
926+
927+// UpdateHostPolicy provides a mock function for the type MockBrokerSession
928+func (_mock *MockBrokerSession) UpdateHostPolicy(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
929+ ret := _mock.Called(ctx, expected, policy)
930+
931+ if len(ret) == 0 {
932+ panic("no return value specified for UpdateHostPolicy")
933+ }
934+
935+ var r0 domain.RemoteRegistration
936+ var r1 error
937+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration, ports.BrokerPolicy) (domain.RemoteRegistration, error)); ok {
938+ return returnFunc(ctx, expected, policy)
939+ }
940+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration, ports.BrokerPolicy) domain.RemoteRegistration); ok {
941+ r0 = returnFunc(ctx, expected, policy)
942+ } else {
943+ r0 = ret.Get(0).(domain.RemoteRegistration)
944+ }
945+ if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RemoteRegistration, ports.BrokerPolicy) error); ok {
946+ r1 = returnFunc(ctx, expected, policy)
947+ } else {
948+ r1 = ret.Error(1)
949+ }
950+ return r0, r1
951+}
952+
953+// MockBrokerSession_UpdateHostPolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateHostPolicy'
954+type MockBrokerSession_UpdateHostPolicy_Call struct {
955+ *mock.Call
956+}
957+
958+// UpdateHostPolicy is a helper method to define mock.On call
959+// - ctx context.Context
960+// - expected domain.RemoteRegistration
961+// - policy ports.BrokerPolicy
962+func (_e *MockBrokerSession_Expecter) UpdateHostPolicy(ctx any, expected any, policy any) *MockBrokerSession_UpdateHostPolicy_Call {
963+ return &MockBrokerSession_UpdateHostPolicy_Call{Call: _e.mock.On("UpdateHostPolicy", ctx, expected, policy)}
964+}
965+
966+func (_c *MockBrokerSession_UpdateHostPolicy_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy)) *MockBrokerSession_UpdateHostPolicy_Call {
967+ _c.Call.Run(func(args mock.Arguments) {
968+ var arg0 context.Context
969+ if args[0] != nil {
970+ arg0 = args[0].(context.Context)
971+ }
972+ var arg1 domain.RemoteRegistration
973+ if args[1] != nil {
974+ arg1 = args[1].(domain.RemoteRegistration)
975+ }
976+ var arg2 ports.BrokerPolicy
977+ if args[2] != nil {
978+ arg2 = args[2].(ports.BrokerPolicy)
979+ }
980+ run(
981+ arg0,
982+ arg1,
983+ arg2,
984+ )
985+ })
986+ return _c
987+}
988+
989+func (_c *MockBrokerSession_UpdateHostPolicy_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerSession_UpdateHostPolicy_Call {
990+ _c.Call.Return(remoteRegistration, err)
991+ return _c
992+}
993+
994+func (_c *MockBrokerSession_UpdateHostPolicy_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerSession_UpdateHostPolicy_Call {
995+ _c.Call.Return(run)
996+ return _c
997+}
998+
271999 // NewMockBrokerService creates a new instance of MockBrokerService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
2721000 // The first argument is typically a *testing.T value.
273-func NewMockBrokerService(t interface {
1001+func NewMockBrokerService(t interface {
1002+ mock.TestingT
1003+ Cleanup(func())
1004+}) *MockBrokerService {
1005+ mock := &MockBrokerService{}
1006+ mock.Mock.Test(t)
1007+
1008+ t.Cleanup(func() { mock.AssertExpectations(t) })
1009+
1010+ return mock
1011+}
1012+
1013+// MockBrokerService is an autogenerated mock type for the BrokerService type
1014+type MockBrokerService struct {
1015+ mock.Mock
1016+}
1017+
1018+type MockBrokerService_Expecter struct {
1019+ mock *mock.Mock
1020+}
1021+
1022+func (_m *MockBrokerService) EXPECT() *MockBrokerService_Expecter {
1023+ return &MockBrokerService_Expecter{mock: &_m.Mock}
1024+}
1025+
1026+// AddHost provides a mock function for the type MockBrokerService
1027+func (_mock *MockBrokerService) AddHost(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
1028+ ret := _mock.Called(ctx, endpoint, policy)
1029+
1030+ if len(ret) == 0 {
1031+ panic("no return value specified for AddHost")
1032+ }
1033+
1034+ var r0 domain.RemoteRegistration
1035+ var r1 error
1036+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, ports.BrokerPolicy) (domain.RemoteRegistration, error)); ok {
1037+ return returnFunc(ctx, endpoint, policy)
1038+ }
1039+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, ports.BrokerPolicy) domain.RemoteRegistration); ok {
1040+ r0 = returnFunc(ctx, endpoint, policy)
1041+ } else {
1042+ r0 = ret.Get(0).(domain.RemoteRegistration)
1043+ }
1044+ if returnFunc, ok := ret.Get(1).(func(context.Context, string, ports.BrokerPolicy) error); ok {
1045+ r1 = returnFunc(ctx, endpoint, policy)
1046+ } else {
1047+ r1 = ret.Error(1)
1048+ }
1049+ return r0, r1
1050+}
1051+
1052+// MockBrokerService_AddHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddHost'
1053+type MockBrokerService_AddHost_Call struct {
1054+ *mock.Call
1055+}
1056+
1057+// AddHost is a helper method to define mock.On call
1058+// - ctx context.Context
1059+// - endpoint string
1060+// - policy ports.BrokerPolicy
1061+func (_e *MockBrokerService_Expecter) AddHost(ctx any, endpoint any, policy any) *MockBrokerService_AddHost_Call {
1062+ return &MockBrokerService_AddHost_Call{Call: _e.mock.On("AddHost", ctx, endpoint, policy)}
1063+}
1064+
1065+func (_c *MockBrokerService_AddHost_Call) Run(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy)) *MockBrokerService_AddHost_Call {
1066+ _c.Call.Run(func(args mock.Arguments) {
1067+ var arg0 context.Context
1068+ if args[0] != nil {
1069+ arg0 = args[0].(context.Context)
1070+ }
1071+ var arg1 string
1072+ if args[1] != nil {
1073+ arg1 = args[1].(string)
1074+ }
1075+ var arg2 ports.BrokerPolicy
1076+ if args[2] != nil {
1077+ arg2 = args[2].(ports.BrokerPolicy)
1078+ }
1079+ run(
1080+ arg0,
1081+ arg1,
1082+ arg2,
1083+ )
1084+ })
1085+ return _c
1086+}
1087+
1088+func (_c *MockBrokerService_AddHost_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerService_AddHost_Call {
1089+ _c.Call.Return(remoteRegistration, err)
1090+ return _c
1091+}
1092+
1093+func (_c *MockBrokerService_AddHost_Call) RunAndReturn(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerService_AddHost_Call {
1094+ _c.Call.Return(run)
1095+ return _c
1096+}
1097+
1098+// Close provides a mock function for the type MockBrokerService
1099+func (_mock *MockBrokerService) Close() error {
1100+ ret := _mock.Called()
1101+
1102+ if len(ret) == 0 {
1103+ panic("no return value specified for Close")
1104+ }
1105+
1106+ var r0 error
1107+ if returnFunc, ok := ret.Get(0).(func() error); ok {
1108+ r0 = returnFunc()
1109+ } else {
1110+ r0 = ret.Error(0)
1111+ }
1112+ return r0
1113+}
1114+
1115+// MockBrokerService_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
1116+type MockBrokerService_Close_Call struct {
1117+ *mock.Call
1118+}
1119+
1120+// Close is a helper method to define mock.On call
1121+func (_e *MockBrokerService_Expecter) Close() *MockBrokerService_Close_Call {
1122+ return &MockBrokerService_Close_Call{Call: _e.mock.On("Close")}
1123+}
1124+
1125+func (_c *MockBrokerService_Close_Call) Run(run func()) *MockBrokerService_Close_Call {
1126+ _c.Call.Run(func(args mock.Arguments) {
1127+ run()
1128+ })
1129+ return _c
1130+}
1131+
1132+func (_c *MockBrokerService_Close_Call) Return(err error) *MockBrokerService_Close_Call {
1133+ _c.Call.Return(err)
1134+ return _c
1135+}
1136+
1137+func (_c *MockBrokerService_Close_Call) RunAndReturn(run func() error) *MockBrokerService_Close_Call {
1138+ _c.Call.Return(run)
1139+ return _c
1140+}
1141+
1142+// CloseStream provides a mock function for the type MockBrokerService
1143+func (_mock *MockBrokerService) CloseStream(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error {
1144+ ret := _mock.Called(connection, stream)
1145+
1146+ if len(ret) == 0 {
1147+ panic("no return value specified for CloseStream")
1148+ }
1149+
1150+ var r0 error
1151+ if returnFunc, ok := ret.Get(0).(func(ports.BrokerConnectionID, ports.BrokerStreamID) error); ok {
1152+ r0 = returnFunc(connection, stream)
1153+ } else {
1154+ r0 = ret.Error(0)
1155+ }
1156+ return r0
1157+}
1158+
1159+// MockBrokerService_CloseStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CloseStream'
1160+type MockBrokerService_CloseStream_Call struct {
1161+ *mock.Call
1162+}
1163+
1164+// CloseStream is a helper method to define mock.On call
1165+// - connection ports.BrokerConnectionID
1166+// - stream ports.BrokerStreamID
1167+func (_e *MockBrokerService_Expecter) CloseStream(connection any, stream any) *MockBrokerService_CloseStream_Call {
1168+ return &MockBrokerService_CloseStream_Call{Call: _e.mock.On("CloseStream", connection, stream)}
1169+}
1170+
1171+func (_c *MockBrokerService_CloseStream_Call) Run(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID)) *MockBrokerService_CloseStream_Call {
1172+ _c.Call.Run(func(args mock.Arguments) {
1173+ var arg0 ports.BrokerConnectionID
1174+ if args[0] != nil {
1175+ arg0 = args[0].(ports.BrokerConnectionID)
1176+ }
1177+ var arg1 ports.BrokerStreamID
1178+ if args[1] != nil {
1179+ arg1 = args[1].(ports.BrokerStreamID)
1180+ }
1181+ run(
1182+ arg0,
1183+ arg1,
1184+ )
1185+ })
1186+ return _c
1187+}
1188+
1189+func (_c *MockBrokerService_CloseStream_Call) Return(err error) *MockBrokerService_CloseStream_Call {
1190+ _c.Call.Return(err)
1191+ return _c
1192+}
1193+
1194+func (_c *MockBrokerService_CloseStream_Call) RunAndReturn(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error) *MockBrokerService_CloseStream_Call {
1195+ _c.Call.Return(run)
1196+ return _c
1197+}
1198+
1199+// ConnectionID provides a mock function for the type MockBrokerService
1200+func (_mock *MockBrokerService) ConnectionID() ports.BrokerConnectionID {
1201+ ret := _mock.Called()
1202+
1203+ if len(ret) == 0 {
1204+ panic("no return value specified for ConnectionID")
1205+ }
1206+
1207+ var r0 ports.BrokerConnectionID
1208+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerConnectionID); ok {
1209+ r0 = returnFunc()
1210+ } else {
1211+ if ret.Get(0) != nil {
1212+ r0 = ret.Get(0).(ports.BrokerConnectionID)
1213+ }
1214+ }
1215+ return r0
1216+}
1217+
1218+// MockBrokerService_ConnectionID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConnectionID'
1219+type MockBrokerService_ConnectionID_Call struct {
1220+ *mock.Call
1221+}
1222+
1223+// ConnectionID is a helper method to define mock.On call
1224+func (_e *MockBrokerService_Expecter) ConnectionID() *MockBrokerService_ConnectionID_Call {
1225+ return &MockBrokerService_ConnectionID_Call{Call: _e.mock.On("ConnectionID")}
1226+}
1227+
1228+func (_c *MockBrokerService_ConnectionID_Call) Run(run func()) *MockBrokerService_ConnectionID_Call {
1229+ _c.Call.Run(func(args mock.Arguments) {
1230+ run()
1231+ })
1232+ return _c
1233+}
1234+
1235+func (_c *MockBrokerService_ConnectionID_Call) Return(brokerConnectionID ports.BrokerConnectionID) *MockBrokerService_ConnectionID_Call {
1236+ _c.Call.Return(brokerConnectionID)
1237+ return _c
1238+}
1239+
1240+func (_c *MockBrokerService_ConnectionID_Call) RunAndReturn(run func() ports.BrokerConnectionID) *MockBrokerService_ConnectionID_Call {
1241+ _c.Call.Return(run)
1242+ return _c
1243+}
1244+
1245+// Done provides a mock function for the type MockBrokerService
1246+func (_mock *MockBrokerService) Done() <-chan struct{} {
1247+ ret := _mock.Called()
1248+
1249+ if len(ret) == 0 {
1250+ panic("no return value specified for Done")
1251+ }
1252+
1253+ var r0 <-chan struct{}
1254+ if returnFunc, ok := ret.Get(0).(func() <-chan struct{}); ok {
1255+ r0 = returnFunc()
1256+ } else {
1257+ if ret.Get(0) != nil {
1258+ r0 = ret.Get(0).(<-chan struct{})
1259+ }
1260+ }
1261+ return r0
1262+}
1263+
1264+// MockBrokerService_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done'
1265+type MockBrokerService_Done_Call struct {
1266+ *mock.Call
1267+}
1268+
1269+// Done is a helper method to define mock.On call
1270+func (_e *MockBrokerService_Expecter) Done() *MockBrokerService_Done_Call {
1271+ return &MockBrokerService_Done_Call{Call: _e.mock.On("Done")}
1272+}
1273+
1274+func (_c *MockBrokerService_Done_Call) Run(run func()) *MockBrokerService_Done_Call {
1275+ _c.Call.Run(func(args mock.Arguments) {
1276+ run()
1277+ })
1278+ return _c
1279+}
1280+
1281+func (_c *MockBrokerService_Done_Call) Return(valCh <-chan struct{}) *MockBrokerService_Done_Call {
1282+ _c.Call.Return(valCh)
1283+ return _c
1284+}
1285+
1286+func (_c *MockBrokerService_Done_Call) RunAndReturn(run func() <-chan struct{}) *MockBrokerService_Done_Call {
1287+ _c.Call.Return(run)
1288+ return _c
1289+}
1290+
1291+// Err provides a mock function for the type MockBrokerService
1292+func (_mock *MockBrokerService) Err() error {
1293+ ret := _mock.Called()
1294+
1295+ if len(ret) == 0 {
1296+ panic("no return value specified for Err")
1297+ }
1298+
1299+ var r0 error
1300+ if returnFunc, ok := ret.Get(0).(func() error); ok {
1301+ r0 = returnFunc()
1302+ } else {
1303+ r0 = ret.Error(0)
1304+ }
1305+ return r0
1306+}
1307+
1308+// MockBrokerService_Err_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Err'
1309+type MockBrokerService_Err_Call struct {
1310+ *mock.Call
1311+}
1312+
1313+// Err is a helper method to define mock.On call
1314+func (_e *MockBrokerService_Expecter) Err() *MockBrokerService_Err_Call {
1315+ return &MockBrokerService_Err_Call{Call: _e.mock.On("Err")}
1316+}
1317+
1318+func (_c *MockBrokerService_Err_Call) Run(run func()) *MockBrokerService_Err_Call {
1319+ _c.Call.Run(func(args mock.Arguments) {
1320+ run()
1321+ })
1322+ return _c
1323+}
1324+
1325+func (_c *MockBrokerService_Err_Call) Return(err error) *MockBrokerService_Err_Call {
1326+ _c.Call.Return(err)
1327+ return _c
1328+}
1329+
1330+func (_c *MockBrokerService_Err_Call) RunAndReturn(run func() error) *MockBrokerService_Err_Call {
1331+ _c.Call.Return(run)
1332+ return _c
1333+}
1334+
1335+// NextStreamID provides a mock function for the type MockBrokerService
1336+func (_mock *MockBrokerService) NextStreamID() (ports.BrokerStreamID, error) {
1337+ ret := _mock.Called()
1338+
1339+ if len(ret) == 0 {
1340+ panic("no return value specified for NextStreamID")
1341+ }
1342+
1343+ var r0 ports.BrokerStreamID
1344+ var r1 error
1345+ if returnFunc, ok := ret.Get(0).(func() (ports.BrokerStreamID, error)); ok {
1346+ return returnFunc()
1347+ }
1348+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerStreamID); ok {
1349+ r0 = returnFunc()
1350+ } else {
1351+ r0 = ret.Get(0).(ports.BrokerStreamID)
1352+ }
1353+ if returnFunc, ok := ret.Get(1).(func() error); ok {
1354+ r1 = returnFunc()
1355+ } else {
1356+ r1 = ret.Error(1)
1357+ }
1358+ return r0, r1
1359+}
1360+
1361+// MockBrokerService_NextStreamID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextStreamID'
1362+type MockBrokerService_NextStreamID_Call struct {
1363+ *mock.Call
1364+}
1365+
1366+// NextStreamID is a helper method to define mock.On call
1367+func (_e *MockBrokerService_Expecter) NextStreamID() *MockBrokerService_NextStreamID_Call {
1368+ return &MockBrokerService_NextStreamID_Call{Call: _e.mock.On("NextStreamID")}
1369+}
1370+
1371+func (_c *MockBrokerService_NextStreamID_Call) Run(run func()) *MockBrokerService_NextStreamID_Call {
1372+ _c.Call.Run(func(args mock.Arguments) {
1373+ run()
1374+ })
1375+ return _c
1376+}
1377+
1378+func (_c *MockBrokerService_NextStreamID_Call) Return(brokerStreamID ports.BrokerStreamID, err error) *MockBrokerService_NextStreamID_Call {
1379+ _c.Call.Return(brokerStreamID, err)
1380+ return _c
1381+}
1382+
1383+func (_c *MockBrokerService_NextStreamID_Call) RunAndReturn(run func() (ports.BrokerStreamID, error)) *MockBrokerService_NextStreamID_Call {
1384+ _c.Call.Return(run)
1385+ return _c
1386+}
1387+
1388+// OpenStream provides a mock function for the type MockBrokerService
1389+func (_mock *MockBrokerService) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
1390+ ret := _mock.Called(ctx, request)
1391+
1392+ if len(ret) == 0 {
1393+ panic("no return value specified for OpenStream")
1394+ }
1395+
1396+ var r0 ports.BrokerLogicalConnection
1397+ var r1 error
1398+ if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error)); ok {
1399+ return returnFunc(ctx, request)
1400+ }
1401+ if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) ports.BrokerLogicalConnection); ok {
1402+ r0 = returnFunc(ctx, request)
1403+ } else {
1404+ if ret.Get(0) != nil {
1405+ r0 = ret.Get(0).(ports.BrokerLogicalConnection)
1406+ }
1407+ }
1408+ if returnFunc, ok := ret.Get(1).(func(context.Context, ports.BrokerOpenStreamRequest) error); ok {
1409+ r1 = returnFunc(ctx, request)
1410+ } else {
1411+ r1 = ret.Error(1)
1412+ }
1413+ return r0, r1
1414+}
1415+
1416+// MockBrokerService_OpenStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OpenStream'
1417+type MockBrokerService_OpenStream_Call struct {
1418+ *mock.Call
1419+}
1420+
1421+// OpenStream is a helper method to define mock.On call
1422+// - ctx context.Context
1423+// - request ports.BrokerOpenStreamRequest
1424+func (_e *MockBrokerService_Expecter) OpenStream(ctx any, request any) *MockBrokerService_OpenStream_Call {
1425+ return &MockBrokerService_OpenStream_Call{Call: _e.mock.On("OpenStream", ctx, request)}
1426+}
1427+
1428+func (_c *MockBrokerService_OpenStream_Call) Run(run func(ctx context.Context, request ports.BrokerOpenStreamRequest)) *MockBrokerService_OpenStream_Call {
1429+ _c.Call.Run(func(args mock.Arguments) {
1430+ var arg0 context.Context
1431+ if args[0] != nil {
1432+ arg0 = args[0].(context.Context)
1433+ }
1434+ var arg1 ports.BrokerOpenStreamRequest
1435+ if args[1] != nil {
1436+ arg1 = args[1].(ports.BrokerOpenStreamRequest)
1437+ }
1438+ run(
1439+ arg0,
1440+ arg1,
1441+ )
1442+ })
1443+ return _c
1444+}
1445+
1446+func (_c *MockBrokerService_OpenStream_Call) Return(brokerLogicalConnection ports.BrokerLogicalConnection, err error) *MockBrokerService_OpenStream_Call {
1447+ _c.Call.Return(brokerLogicalConnection, err)
1448+ return _c
1449+}
1450+
1451+func (_c *MockBrokerService_OpenStream_Call) RunAndReturn(run func(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error)) *MockBrokerService_OpenStream_Call {
1452+ _c.Call.Return(run)
1453+ return _c
1454+}
1455+
1456+// RemoveHost provides a mock function for the type MockBrokerService
1457+func (_mock *MockBrokerService) RemoveHost(ctx context.Context, expected domain.RemoteRegistration) (bool, error) {
1458+ ret := _mock.Called(ctx, expected)
1459+
1460+ if len(ret) == 0 {
1461+ panic("no return value specified for RemoveHost")
1462+ }
1463+
1464+ var r0 bool
1465+ var r1 error
1466+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration) (bool, error)); ok {
1467+ return returnFunc(ctx, expected)
1468+ }
1469+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration) bool); ok {
1470+ r0 = returnFunc(ctx, expected)
1471+ } else {
1472+ r0 = ret.Get(0).(bool)
1473+ }
1474+ if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RemoteRegistration) error); ok {
1475+ r1 = returnFunc(ctx, expected)
1476+ } else {
1477+ r1 = ret.Error(1)
1478+ }
1479+ return r0, r1
1480+}
1481+
1482+// MockBrokerService_RemoveHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveHost'
1483+type MockBrokerService_RemoveHost_Call struct {
1484+ *mock.Call
1485+}
1486+
1487+// RemoveHost is a helper method to define mock.On call
1488+// - ctx context.Context
1489+// - expected domain.RemoteRegistration
1490+func (_e *MockBrokerService_Expecter) RemoveHost(ctx any, expected any) *MockBrokerService_RemoveHost_Call {
1491+ return &MockBrokerService_RemoveHost_Call{Call: _e.mock.On("RemoveHost", ctx, expected)}
1492+}
1493+
1494+func (_c *MockBrokerService_RemoveHost_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration)) *MockBrokerService_RemoveHost_Call {
1495+ _c.Call.Run(func(args mock.Arguments) {
1496+ var arg0 context.Context
1497+ if args[0] != nil {
1498+ arg0 = args[0].(context.Context)
1499+ }
1500+ var arg1 domain.RemoteRegistration
1501+ if args[1] != nil {
1502+ arg1 = args[1].(domain.RemoteRegistration)
1503+ }
1504+ run(
1505+ arg0,
1506+ arg1,
1507+ )
1508+ })
1509+ return _c
1510+}
1511+
1512+func (_c *MockBrokerService_RemoveHost_Call) Return(b bool, err error) *MockBrokerService_RemoveHost_Call {
1513+ _c.Call.Return(b, err)
1514+ return _c
1515+}
1516+
1517+func (_c *MockBrokerService_RemoveHost_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration) (bool, error)) *MockBrokerService_RemoveHost_Call {
1518+ _c.Call.Return(run)
1519+ return _c
1520+}
1521+
1522+// RequestReconcile provides a mock function for the type MockBrokerService
1523+func (_mock *MockBrokerService) RequestReconcile(endpoint string) {
1524+ _mock.Called(endpoint)
1525+ return
1526+}
1527+
1528+// MockBrokerService_RequestReconcile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestReconcile'
1529+type MockBrokerService_RequestReconcile_Call struct {
1530+ *mock.Call
1531+}
1532+
1533+// RequestReconcile is a helper method to define mock.On call
1534+// - endpoint string
1535+func (_e *MockBrokerService_Expecter) RequestReconcile(endpoint any) *MockBrokerService_RequestReconcile_Call {
1536+ return &MockBrokerService_RequestReconcile_Call{Call: _e.mock.On("RequestReconcile", endpoint)}
1537+}
1538+
1539+func (_c *MockBrokerService_RequestReconcile_Call) Run(run func(endpoint string)) *MockBrokerService_RequestReconcile_Call {
1540+ _c.Call.Run(func(args mock.Arguments) {
1541+ var arg0 string
1542+ if args[0] != nil {
1543+ arg0 = args[0].(string)
1544+ }
1545+ run(
1546+ arg0,
1547+ )
1548+ })
1549+ return _c
1550+}
1551+
1552+func (_c *MockBrokerService_RequestReconcile_Call) Return() *MockBrokerService_RequestReconcile_Call {
1553+ _c.Call.Return()
1554+ return _c
1555+}
1556+
1557+func (_c *MockBrokerService_RequestReconcile_Call) RunAndReturn(run func(endpoint string)) *MockBrokerService_RequestReconcile_Call {
1558+ _c.Run(run)
1559+ return _c
1560+}
1561+
1562+// Snapshot provides a mock function for the type MockBrokerService
1563+func (_mock *MockBrokerService) Snapshot() ports.BrokerSnapshot {
1564+ ret := _mock.Called()
1565+
1566+ if len(ret) == 0 {
1567+ panic("no return value specified for Snapshot")
1568+ }
1569+
1570+ var r0 ports.BrokerSnapshot
1571+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerSnapshot); ok {
1572+ r0 = returnFunc()
1573+ } else {
1574+ r0 = ret.Get(0).(ports.BrokerSnapshot)
1575+ }
1576+ return r0
1577+}
1578+
1579+// MockBrokerService_Snapshot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Snapshot'
1580+type MockBrokerService_Snapshot_Call struct {
1581+ *mock.Call
1582+}
1583+
1584+// Snapshot is a helper method to define mock.On call
1585+func (_e *MockBrokerService_Expecter) Snapshot() *MockBrokerService_Snapshot_Call {
1586+ return &MockBrokerService_Snapshot_Call{Call: _e.mock.On("Snapshot")}
1587+}
1588+
1589+func (_c *MockBrokerService_Snapshot_Call) Run(run func()) *MockBrokerService_Snapshot_Call {
1590+ _c.Call.Run(func(args mock.Arguments) {
1591+ run()
1592+ })
1593+ return _c
1594+}
1595+
1596+func (_c *MockBrokerService_Snapshot_Call) Return(brokerSnapshot ports.BrokerSnapshot) *MockBrokerService_Snapshot_Call {
1597+ _c.Call.Return(brokerSnapshot)
1598+ return _c
1599+}
1600+
1601+func (_c *MockBrokerService_Snapshot_Call) RunAndReturn(run func() ports.BrokerSnapshot) *MockBrokerService_Snapshot_Call {
1602+ _c.Call.Return(run)
1603+ return _c
1604+}
1605+
1606+// Subscribe provides a mock function for the type MockBrokerService
1607+func (_mock *MockBrokerService) Subscribe() (ports.BrokerSubscription, error) {
1608+ ret := _mock.Called()
1609+
1610+ if len(ret) == 0 {
1611+ panic("no return value specified for Subscribe")
1612+ }
1613+
1614+ var r0 ports.BrokerSubscription
1615+ var r1 error
1616+ if returnFunc, ok := ret.Get(0).(func() (ports.BrokerSubscription, error)); ok {
1617+ return returnFunc()
1618+ }
1619+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerSubscription); ok {
1620+ r0 = returnFunc()
1621+ } else {
1622+ if ret.Get(0) != nil {
1623+ r0 = ret.Get(0).(ports.BrokerSubscription)
1624+ }
1625+ }
1626+ if returnFunc, ok := ret.Get(1).(func() error); ok {
1627+ r1 = returnFunc()
1628+ } else {
1629+ r1 = ret.Error(1)
1630+ }
1631+ return r0, r1
1632+}
1633+
1634+// MockBrokerService_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe'
1635+type MockBrokerService_Subscribe_Call struct {
1636+ *mock.Call
1637+}
1638+
1639+// Subscribe is a helper method to define mock.On call
1640+func (_e *MockBrokerService_Expecter) Subscribe() *MockBrokerService_Subscribe_Call {
1641+ return &MockBrokerService_Subscribe_Call{Call: _e.mock.On("Subscribe")}
1642+}
1643+
1644+func (_c *MockBrokerService_Subscribe_Call) Run(run func()) *MockBrokerService_Subscribe_Call {
1645+ _c.Call.Run(func(args mock.Arguments) {
1646+ run()
1647+ })
1648+ return _c
1649+}
1650+
1651+func (_c *MockBrokerService_Subscribe_Call) Return(brokerSubscription ports.BrokerSubscription, err error) *MockBrokerService_Subscribe_Call {
1652+ _c.Call.Return(brokerSubscription, err)
1653+ return _c
1654+}
1655+
1656+func (_c *MockBrokerService_Subscribe_Call) RunAndReturn(run func() (ports.BrokerSubscription, error)) *MockBrokerService_Subscribe_Call {
1657+ _c.Call.Return(run)
1658+ return _c
1659+}
1660+
1661+// SubscribePreview provides a mock function for the type MockBrokerService
1662+func (_mock *MockBrokerService) SubscribePreview(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error) {
1663+ ret := _mock.Called(request)
1664+
1665+ if len(ret) == 0 {
1666+ panic("no return value specified for SubscribePreview")
1667+ }
1668+
1669+ var r0 ports.BrokerPreviewSubscription
1670+ var r1 error
1671+ if returnFunc, ok := ret.Get(0).(func(ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error)); ok {
1672+ return returnFunc(request)
1673+ }
1674+ if returnFunc, ok := ret.Get(0).(func(ports.BrokerPreviewRequest) ports.BrokerPreviewSubscription); ok {
1675+ r0 = returnFunc(request)
1676+ } else {
1677+ if ret.Get(0) != nil {
1678+ r0 = ret.Get(0).(ports.BrokerPreviewSubscription)
1679+ }
1680+ }
1681+ if returnFunc, ok := ret.Get(1).(func(ports.BrokerPreviewRequest) error); ok {
1682+ r1 = returnFunc(request)
1683+ } else {
1684+ r1 = ret.Error(1)
1685+ }
1686+ return r0, r1
1687+}
1688+
1689+// MockBrokerService_SubscribePreview_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribePreview'
1690+type MockBrokerService_SubscribePreview_Call struct {
1691+ *mock.Call
1692+}
1693+
1694+// SubscribePreview is a helper method to define mock.On call
1695+// - request ports.BrokerPreviewRequest
1696+func (_e *MockBrokerService_Expecter) SubscribePreview(request any) *MockBrokerService_SubscribePreview_Call {
1697+ return &MockBrokerService_SubscribePreview_Call{Call: _e.mock.On("SubscribePreview", request)}
1698+}
1699+
1700+func (_c *MockBrokerService_SubscribePreview_Call) Run(run func(request ports.BrokerPreviewRequest)) *MockBrokerService_SubscribePreview_Call {
1701+ _c.Call.Run(func(args mock.Arguments) {
1702+ var arg0 ports.BrokerPreviewRequest
1703+ if args[0] != nil {
1704+ arg0 = args[0].(ports.BrokerPreviewRequest)
1705+ }
1706+ run(
1707+ arg0,
1708+ )
1709+ })
1710+ return _c
1711+}
1712+
1713+func (_c *MockBrokerService_SubscribePreview_Call) Return(brokerPreviewSubscription ports.BrokerPreviewSubscription, err error) *MockBrokerService_SubscribePreview_Call {
1714+ _c.Call.Return(brokerPreviewSubscription, err)
1715+ return _c
1716+}
1717+
1718+func (_c *MockBrokerService_SubscribePreview_Call) RunAndReturn(run func(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error)) *MockBrokerService_SubscribePreview_Call {
1719+ _c.Call.Return(run)
1720+ return _c
1721+}
1722+
1723+// UpdateHostPolicy provides a mock function for the type MockBrokerService
1724+func (_mock *MockBrokerService) UpdateHostPolicy(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
1725+ ret := _mock.Called(ctx, expected, policy)
1726+
1727+ if len(ret) == 0 {
1728+ panic("no return value specified for UpdateHostPolicy")
1729+ }
1730+
1731+ var r0 domain.RemoteRegistration
1732+ var r1 error
1733+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration, ports.BrokerPolicy) (domain.RemoteRegistration, error)); ok {
1734+ return returnFunc(ctx, expected, policy)
1735+ }
1736+ if returnFunc, ok := ret.Get(0).(func(context.Context, domain.RemoteRegistration, ports.BrokerPolicy) domain.RemoteRegistration); ok {
1737+ r0 = returnFunc(ctx, expected, policy)
1738+ } else {
1739+ r0 = ret.Get(0).(domain.RemoteRegistration)
1740+ }
1741+ if returnFunc, ok := ret.Get(1).(func(context.Context, domain.RemoteRegistration, ports.BrokerPolicy) error); ok {
1742+ r1 = returnFunc(ctx, expected, policy)
1743+ } else {
1744+ r1 = ret.Error(1)
1745+ }
1746+ return r0, r1
1747+}
1748+
1749+// MockBrokerService_UpdateHostPolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateHostPolicy'
1750+type MockBrokerService_UpdateHostPolicy_Call struct {
1751+ *mock.Call
1752+}
1753+
1754+// UpdateHostPolicy is a helper method to define mock.On call
1755+// - ctx context.Context
1756+// - expected domain.RemoteRegistration
1757+// - policy ports.BrokerPolicy
1758+func (_e *MockBrokerService_Expecter) UpdateHostPolicy(ctx any, expected any, policy any) *MockBrokerService_UpdateHostPolicy_Call {
1759+ return &MockBrokerService_UpdateHostPolicy_Call{Call: _e.mock.On("UpdateHostPolicy", ctx, expected, policy)}
1760+}
1761+
1762+func (_c *MockBrokerService_UpdateHostPolicy_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy)) *MockBrokerService_UpdateHostPolicy_Call {
1763+ _c.Call.Run(func(args mock.Arguments) {
1764+ var arg0 context.Context
1765+ if args[0] != nil {
1766+ arg0 = args[0].(context.Context)
1767+ }
1768+ var arg1 domain.RemoteRegistration
1769+ if args[1] != nil {
1770+ arg1 = args[1].(domain.RemoteRegistration)
1771+ }
1772+ var arg2 ports.BrokerPolicy
1773+ if args[2] != nil {
1774+ arg2 = args[2].(ports.BrokerPolicy)
1775+ }
1776+ run(
1777+ arg0,
1778+ arg1,
1779+ arg2,
1780+ )
1781+ })
1782+ return _c
1783+}
1784+
1785+func (_c *MockBrokerService_UpdateHostPolicy_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerService_UpdateHostPolicy_Call {
1786+ _c.Call.Return(remoteRegistration, err)
1787+ return _c
1788+}
1789+
1790+func (_c *MockBrokerService_UpdateHostPolicy_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerService_UpdateHostPolicy_Call {
1791+ _c.Call.Return(run)
1792+ return _c
1793+}
1794+
1795+// NewMockBrokerEnvelopeStream creates a new instance of MockBrokerEnvelopeStream. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
1796+// The first argument is typically a *testing.T value.
1797+func NewMockBrokerEnvelopeStream(t interface {
1798+ mock.TestingT
1799+ Cleanup(func())
1800+}) *MockBrokerEnvelopeStream {
1801+ mock := &MockBrokerEnvelopeStream{}
1802+ mock.Mock.Test(t)
1803+
1804+ t.Cleanup(func() { mock.AssertExpectations(t) })
1805+
1806+ return mock
1807+}
1808+
1809+// MockBrokerEnvelopeStream is an autogenerated mock type for the BrokerEnvelopeStream type
1810+type MockBrokerEnvelopeStream struct {
1811+ mock.Mock
1812+}
1813+
1814+type MockBrokerEnvelopeStream_Expecter struct {
1815+ mock *mock.Mock
1816+}
1817+
1818+func (_m *MockBrokerEnvelopeStream) EXPECT() *MockBrokerEnvelopeStream_Expecter {
1819+ return &MockBrokerEnvelopeStream_Expecter{mock: &_m.Mock}
1820+}
1821+
1822+// Close provides a mock function for the type MockBrokerEnvelopeStream
1823+func (_mock *MockBrokerEnvelopeStream) Close() error {
1824+ ret := _mock.Called()
1825+
1826+ if len(ret) == 0 {
1827+ panic("no return value specified for Close")
1828+ }
1829+
1830+ var r0 error
1831+ if returnFunc, ok := ret.Get(0).(func() error); ok {
1832+ r0 = returnFunc()
1833+ } else {
1834+ r0 = ret.Error(0)
1835+ }
1836+ return r0
1837+}
1838+
1839+// MockBrokerEnvelopeStream_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
1840+type MockBrokerEnvelopeStream_Close_Call struct {
1841+ *mock.Call
1842+}
1843+
1844+// Close is a helper method to define mock.On call
1845+func (_e *MockBrokerEnvelopeStream_Expecter) Close() *MockBrokerEnvelopeStream_Close_Call {
1846+ return &MockBrokerEnvelopeStream_Close_Call{Call: _e.mock.On("Close")}
1847+}
1848+
1849+func (_c *MockBrokerEnvelopeStream_Close_Call) Run(run func()) *MockBrokerEnvelopeStream_Close_Call {
1850+ _c.Call.Run(func(args mock.Arguments) {
1851+ run()
1852+ })
1853+ return _c
1854+}
1855+
1856+func (_c *MockBrokerEnvelopeStream_Close_Call) Return(err error) *MockBrokerEnvelopeStream_Close_Call {
1857+ _c.Call.Return(err)
1858+ return _c
1859+}
1860+
1861+func (_c *MockBrokerEnvelopeStream_Close_Call) RunAndReturn(run func() error) *MockBrokerEnvelopeStream_Close_Call {
1862+ _c.Call.Return(run)
1863+ return _c
1864+}
1865+
1866+// Done provides a mock function for the type MockBrokerEnvelopeStream
1867+func (_mock *MockBrokerEnvelopeStream) Done() <-chan struct{} {
1868+ ret := _mock.Called()
1869+
1870+ if len(ret) == 0 {
1871+ panic("no return value specified for Done")
1872+ }
1873+
1874+ var r0 <-chan struct{}
1875+ if returnFunc, ok := ret.Get(0).(func() <-chan struct{}); ok {
1876+ r0 = returnFunc()
1877+ } else {
1878+ if ret.Get(0) != nil {
1879+ r0 = ret.Get(0).(<-chan struct{})
1880+ }
1881+ }
1882+ return r0
1883+}
1884+
1885+// MockBrokerEnvelopeStream_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done'
1886+type MockBrokerEnvelopeStream_Done_Call struct {
1887+ *mock.Call
1888+}
1889+
1890+// Done is a helper method to define mock.On call
1891+func (_e *MockBrokerEnvelopeStream_Expecter) Done() *MockBrokerEnvelopeStream_Done_Call {
1892+ return &MockBrokerEnvelopeStream_Done_Call{Call: _e.mock.On("Done")}
1893+}
1894+
1895+func (_c *MockBrokerEnvelopeStream_Done_Call) Run(run func()) *MockBrokerEnvelopeStream_Done_Call {
1896+ _c.Call.Run(func(args mock.Arguments) {
1897+ run()
1898+ })
1899+ return _c
1900+}
1901+
1902+func (_c *MockBrokerEnvelopeStream_Done_Call) Return(valCh <-chan struct{}) *MockBrokerEnvelopeStream_Done_Call {
1903+ _c.Call.Return(valCh)
1904+ return _c
1905+}
1906+
1907+func (_c *MockBrokerEnvelopeStream_Done_Call) RunAndReturn(run func() <-chan struct{}) *MockBrokerEnvelopeStream_Done_Call {
1908+ _c.Call.Return(run)
1909+ return _c
1910+}
1911+
1912+// Err provides a mock function for the type MockBrokerEnvelopeStream
1913+func (_mock *MockBrokerEnvelopeStream) Err() error {
1914+ ret := _mock.Called()
1915+
1916+ if len(ret) == 0 {
1917+ panic("no return value specified for Err")
1918+ }
1919+
1920+ var r0 error
1921+ if returnFunc, ok := ret.Get(0).(func() error); ok {
1922+ r0 = returnFunc()
1923+ } else {
1924+ r0 = ret.Error(0)
1925+ }
1926+ return r0
1927+}
1928+
1929+// MockBrokerEnvelopeStream_Err_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Err'
1930+type MockBrokerEnvelopeStream_Err_Call struct {
1931+ *mock.Call
1932+}
1933+
1934+// Err is a helper method to define mock.On call
1935+func (_e *MockBrokerEnvelopeStream_Expecter) Err() *MockBrokerEnvelopeStream_Err_Call {
1936+ return &MockBrokerEnvelopeStream_Err_Call{Call: _e.mock.On("Err")}
1937+}
1938+
1939+func (_c *MockBrokerEnvelopeStream_Err_Call) Run(run func()) *MockBrokerEnvelopeStream_Err_Call {
1940+ _c.Call.Run(func(args mock.Arguments) {
1941+ run()
1942+ })
1943+ return _c
1944+}
1945+
1946+func (_c *MockBrokerEnvelopeStream_Err_Call) Return(err error) *MockBrokerEnvelopeStream_Err_Call {
1947+ _c.Call.Return(err)
1948+ return _c
1949+}
1950+
1951+func (_c *MockBrokerEnvelopeStream_Err_Call) RunAndReturn(run func() error) *MockBrokerEnvelopeStream_Err_Call {
1952+ _c.Call.Return(run)
1953+ return _c
1954+}
1955+
1956+// RecvEnvelope provides a mock function for the type MockBrokerEnvelopeStream
1957+func (_mock *MockBrokerEnvelopeStream) RecvEnvelope() ([]byte, error) {
1958+ ret := _mock.Called()
1959+
1960+ if len(ret) == 0 {
1961+ panic("no return value specified for RecvEnvelope")
1962+ }
1963+
1964+ var r0 []byte
1965+ var r1 error
1966+ if returnFunc, ok := ret.Get(0).(func() ([]byte, error)); ok {
1967+ return returnFunc()
1968+ }
1969+ if returnFunc, ok := ret.Get(0).(func() []byte); ok {
1970+ r0 = returnFunc()
1971+ } else {
1972+ if ret.Get(0) != nil {
1973+ r0 = ret.Get(0).([]byte)
1974+ }
1975+ }
1976+ if returnFunc, ok := ret.Get(1).(func() error); ok {
1977+ r1 = returnFunc()
1978+ } else {
1979+ r1 = ret.Error(1)
1980+ }
1981+ return r0, r1
1982+}
1983+
1984+// MockBrokerEnvelopeStream_RecvEnvelope_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RecvEnvelope'
1985+type MockBrokerEnvelopeStream_RecvEnvelope_Call struct {
1986+ *mock.Call
1987+}
1988+
1989+// RecvEnvelope is a helper method to define mock.On call
1990+func (_e *MockBrokerEnvelopeStream_Expecter) RecvEnvelope() *MockBrokerEnvelopeStream_RecvEnvelope_Call {
1991+ return &MockBrokerEnvelopeStream_RecvEnvelope_Call{Call: _e.mock.On("RecvEnvelope")}
1992+}
1993+
1994+func (_c *MockBrokerEnvelopeStream_RecvEnvelope_Call) Run(run func()) *MockBrokerEnvelopeStream_RecvEnvelope_Call {
1995+ _c.Call.Run(func(args mock.Arguments) {
1996+ run()
1997+ })
1998+ return _c
1999+}
2000+
2001+func (_c *MockBrokerEnvelopeStream_RecvEnvelope_Call) Return(bytes []byte, err error) *MockBrokerEnvelopeStream_RecvEnvelope_Call {
2002+ _c.Call.Return(bytes, err)
2003+ return _c
2004+}
2005+
2006+func (_c *MockBrokerEnvelopeStream_RecvEnvelope_Call) RunAndReturn(run func() ([]byte, error)) *MockBrokerEnvelopeStream_RecvEnvelope_Call {
2007+ _c.Call.Return(run)
2008+ return _c
2009+}
2010+
2011+// SendEnvelope provides a mock function for the type MockBrokerEnvelopeStream
2012+func (_mock *MockBrokerEnvelopeStream) SendEnvelope(bytes []byte) error {
2013+ ret := _mock.Called(bytes)
2014+
2015+ if len(ret) == 0 {
2016+ panic("no return value specified for SendEnvelope")
2017+ }
2018+
2019+ var r0 error
2020+ if returnFunc, ok := ret.Get(0).(func([]byte) error); ok {
2021+ r0 = returnFunc(bytes)
2022+ } else {
2023+ r0 = ret.Error(0)
2024+ }
2025+ return r0
2026+}
2027+
2028+// MockBrokerEnvelopeStream_SendEnvelope_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendEnvelope'
2029+type MockBrokerEnvelopeStream_SendEnvelope_Call struct {
2030+ *mock.Call
2031+}
2032+
2033+// SendEnvelope is a helper method to define mock.On call
2034+// - bytes []byte
2035+func (_e *MockBrokerEnvelopeStream_Expecter) SendEnvelope(bytes any) *MockBrokerEnvelopeStream_SendEnvelope_Call {
2036+ return &MockBrokerEnvelopeStream_SendEnvelope_Call{Call: _e.mock.On("SendEnvelope", bytes)}
2037+}
2038+
2039+func (_c *MockBrokerEnvelopeStream_SendEnvelope_Call) Run(run func(bytes []byte)) *MockBrokerEnvelopeStream_SendEnvelope_Call {
2040+ _c.Call.Run(func(args mock.Arguments) {
2041+ var arg0 []byte
2042+ if args[0] != nil {
2043+ arg0 = args[0].([]byte)
2044+ }
2045+ run(
2046+ arg0,
2047+ )
2048+ })
2049+ return _c
2050+}
2051+
2052+func (_c *MockBrokerEnvelopeStream_SendEnvelope_Call) Return(err error) *MockBrokerEnvelopeStream_SendEnvelope_Call {
2053+ _c.Call.Return(err)
2054+ return _c
2055+}
2056+
2057+func (_c *MockBrokerEnvelopeStream_SendEnvelope_Call) RunAndReturn(run func(bytes []byte) error) *MockBrokerEnvelopeStream_SendEnvelope_Call {
2058+ _c.Call.Return(run)
2059+ return _c
2060+}
2061+
2062+// NewMockBrokerCoreService creates a new instance of MockBrokerCoreService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
2063+// The first argument is typically a *testing.T value.
2064+func NewMockBrokerCoreService(t interface {
2742065 mock.TestingT
2752066 Cleanup(func())
276-}) *MockBrokerService {
277- mock := &MockBrokerService{}
2067+}) *MockBrokerCoreService {
2068+ mock := &MockBrokerCoreService{}
2782069 mock.Mock.Test(t)
2792070
2802071 t.Cleanup(func() { mock.AssertExpectations(t) })
@@ -282,21 +2073,21 @@ func NewMockBrokerService(t interface {
2822073 return mock
2832074 }
2842075
285-// MockBrokerService is an autogenerated mock type for the BrokerService type
286-type MockBrokerService struct {
2076+// MockBrokerCoreService is an autogenerated mock type for the BrokerCoreService type
2077+type MockBrokerCoreService struct {
2872078 mock.Mock
2882079 }
2892080
290-type MockBrokerService_Expecter struct {
2081+type MockBrokerCoreService_Expecter struct {
2912082 mock *mock.Mock
2922083 }
2932084
294-func (_m *MockBrokerService) EXPECT() *MockBrokerService_Expecter {
295- return &MockBrokerService_Expecter{mock: &_m.Mock}
2085+func (_m *MockBrokerCoreService) EXPECT() *MockBrokerCoreService_Expecter {
2086+ return &MockBrokerCoreService_Expecter{mock: &_m.Mock}
2962087 }
2972088
298-// AddHost provides a mock function for the type MockBrokerService
299-func (_mock *MockBrokerService) AddHost(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
2089+// AddHost provides a mock function for the type MockBrokerCoreService
2090+func (_mock *MockBrokerCoreService) AddHost(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
3002091 ret := _mock.Called(ctx, endpoint, policy)
3012092
3022093 if len(ret) == 0 {
@@ -321,8 +2112,8 @@ func (_mock *MockBrokerService) AddHost(ctx context.Context, endpoint string, po
3212112 return r0, r1
3222113 }
3232114
324-// MockBrokerService_AddHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddHost'
325-type MockBrokerService_AddHost_Call struct {
2115+// MockBrokerCoreService_AddHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddHost'
2116+type MockBrokerCoreService_AddHost_Call struct {
3262117 *mock.Call
3272118 }
3282119
@@ -330,11 +2121,11 @@ type MockBrokerService_AddHost_Call struct {
3302121 // - ctx context.Context
3312122 // - endpoint string
3322123 // - policy ports.BrokerPolicy
333-func (_e *MockBrokerService_Expecter) AddHost(ctx any, endpoint any, policy any) *MockBrokerService_AddHost_Call {
334- return &MockBrokerService_AddHost_Call{Call: _e.mock.On("AddHost", ctx, endpoint, policy)}
2124+func (_e *MockBrokerCoreService_Expecter) AddHost(ctx any, endpoint any, policy any) *MockBrokerCoreService_AddHost_Call {
2125+ return &MockBrokerCoreService_AddHost_Call{Call: _e.mock.On("AddHost", ctx, endpoint, policy)}
3352126 }
3362127
337-func (_c *MockBrokerService_AddHost_Call) Run(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy)) *MockBrokerService_AddHost_Call {
2128+func (_c *MockBrokerCoreService_AddHost_Call) Run(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy)) *MockBrokerCoreService_AddHost_Call {
3382129 _c.Call.Run(func(args mock.Arguments) {
3392130 var arg0 context.Context
3402131 if args[0] != nil {
@@ -357,18 +2148,18 @@ func (_c *MockBrokerService_AddHost_Call) Run(run func(ctx context.Context, endp
3572148 return _c
3582149 }
3592150
360-func (_c *MockBrokerService_AddHost_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerService_AddHost_Call {
2151+func (_c *MockBrokerCoreService_AddHost_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerCoreService_AddHost_Call {
3612152 _c.Call.Return(remoteRegistration, err)
3622153 return _c
3632154 }
3642155
365-func (_c *MockBrokerService_AddHost_Call) RunAndReturn(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerService_AddHost_Call {
2156+func (_c *MockBrokerCoreService_AddHost_Call) RunAndReturn(run func(ctx context.Context, endpoint string, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerCoreService_AddHost_Call {
3662157 _c.Call.Return(run)
3672158 return _c
3682159 }
3692160
370-// Close provides a mock function for the type MockBrokerService
371-func (_mock *MockBrokerService) Close() error {
2161+// Close provides a mock function for the type MockBrokerCoreService
2162+func (_mock *MockBrokerCoreService) Close() error {
3722163 ret := _mock.Called()
3732164
3742165 if len(ret) == 0 {
@@ -384,35 +2175,35 @@ func (_mock *MockBrokerService) Close() error {
3842175 return r0
3852176 }
3862177
387-// MockBrokerService_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
388-type MockBrokerService_Close_Call struct {
2178+// MockBrokerCoreService_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
2179+type MockBrokerCoreService_Close_Call struct {
3892180 *mock.Call
3902181 }
3912182
3922183 // Close is a helper method to define mock.On call
393-func (_e *MockBrokerService_Expecter) Close() *MockBrokerService_Close_Call {
394- return &MockBrokerService_Close_Call{Call: _e.mock.On("Close")}
2184+func (_e *MockBrokerCoreService_Expecter) Close() *MockBrokerCoreService_Close_Call {
2185+ return &MockBrokerCoreService_Close_Call{Call: _e.mock.On("Close")}
3952186 }
3962187
397-func (_c *MockBrokerService_Close_Call) Run(run func()) *MockBrokerService_Close_Call {
2188+func (_c *MockBrokerCoreService_Close_Call) Run(run func()) *MockBrokerCoreService_Close_Call {
3982189 _c.Call.Run(func(args mock.Arguments) {
3992190 run()
4002191 })
4012192 return _c
4022193 }
4032194
404-func (_c *MockBrokerService_Close_Call) Return(err error) *MockBrokerService_Close_Call {
2195+func (_c *MockBrokerCoreService_Close_Call) Return(err error) *MockBrokerCoreService_Close_Call {
4052196 _c.Call.Return(err)
4062197 return _c
4072198 }
4082199
409-func (_c *MockBrokerService_Close_Call) RunAndReturn(run func() error) *MockBrokerService_Close_Call {
2200+func (_c *MockBrokerCoreService_Close_Call) RunAndReturn(run func() error) *MockBrokerCoreService_Close_Call {
4102201 _c.Call.Return(run)
4112202 return _c
4122203 }
4132204
414-// CloseStream provides a mock function for the type MockBrokerService
415-func (_mock *MockBrokerService) CloseStream(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error {
2205+// CloseStream provides a mock function for the type MockBrokerCoreService
2206+func (_mock *MockBrokerCoreService) CloseStream(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error {
4162207 ret := _mock.Called(connection, stream)
4172208
4182209 if len(ret) == 0 {
@@ -428,19 +2219,19 @@ func (_mock *MockBrokerService) CloseStream(connection ports.BrokerConnectionID,
4282219 return r0
4292220 }
4302221
431-// MockBrokerService_CloseStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CloseStream'
432-type MockBrokerService_CloseStream_Call struct {
2222+// MockBrokerCoreService_CloseStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CloseStream'
2223+type MockBrokerCoreService_CloseStream_Call struct {
4332224 *mock.Call
4342225 }
4352226
4362227 // CloseStream is a helper method to define mock.On call
4372228 // - connection ports.BrokerConnectionID
4382229 // - stream ports.BrokerStreamID
439-func (_e *MockBrokerService_Expecter) CloseStream(connection any, stream any) *MockBrokerService_CloseStream_Call {
440- return &MockBrokerService_CloseStream_Call{Call: _e.mock.On("CloseStream", connection, stream)}
2230+func (_e *MockBrokerCoreService_Expecter) CloseStream(connection any, stream any) *MockBrokerCoreService_CloseStream_Call {
2231+ return &MockBrokerCoreService_CloseStream_Call{Call: _e.mock.On("CloseStream", connection, stream)}
4412232 }
4422233
443-func (_c *MockBrokerService_CloseStream_Call) Run(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID)) *MockBrokerService_CloseStream_Call {
2234+func (_c *MockBrokerCoreService_CloseStream_Call) Run(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID)) *MockBrokerCoreService_CloseStream_Call {
4442235 _c.Call.Run(func(args mock.Arguments) {
4452236 var arg0 ports.BrokerConnectionID
4462237 if args[0] != nil {
@@ -458,18 +2249,18 @@ func (_c *MockBrokerService_CloseStream_Call) Run(run func(connection ports.Brok
4582249 return _c
4592250 }
4602251
461-func (_c *MockBrokerService_CloseStream_Call) Return(err error) *MockBrokerService_CloseStream_Call {
2252+func (_c *MockBrokerCoreService_CloseStream_Call) Return(err error) *MockBrokerCoreService_CloseStream_Call {
4622253 _c.Call.Return(err)
4632254 return _c
4642255 }
4652256
466-func (_c *MockBrokerService_CloseStream_Call) RunAndReturn(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error) *MockBrokerService_CloseStream_Call {
2257+func (_c *MockBrokerCoreService_CloseStream_Call) RunAndReturn(run func(connection ports.BrokerConnectionID, stream ports.BrokerStreamID) error) *MockBrokerCoreService_CloseStream_Call {
4672258 _c.Call.Return(run)
4682259 return _c
4692260 }
4702261
471-// ConnectionID provides a mock function for the type MockBrokerService
472-func (_mock *MockBrokerService) ConnectionID() ports.BrokerConnectionID {
2262+// ConnectionID provides a mock function for the type MockBrokerCoreService
2263+func (_mock *MockBrokerCoreService) ConnectionID() ports.BrokerConnectionID {
4732264 ret := _mock.Called()
4742265
4752266 if len(ret) == 0 {
@@ -487,35 +2278,35 @@ func (_mock *MockBrokerService) ConnectionID() ports.BrokerConnectionID {
4872278 return r0
4882279 }
4892280
490-// MockBrokerService_ConnectionID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConnectionID'
491-type MockBrokerService_ConnectionID_Call struct {
2281+// MockBrokerCoreService_ConnectionID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConnectionID'
2282+type MockBrokerCoreService_ConnectionID_Call struct {
4922283 *mock.Call
4932284 }
4942285
4952286 // ConnectionID is a helper method to define mock.On call
496-func (_e *MockBrokerService_Expecter) ConnectionID() *MockBrokerService_ConnectionID_Call {
497- return &MockBrokerService_ConnectionID_Call{Call: _e.mock.On("ConnectionID")}
2287+func (_e *MockBrokerCoreService_Expecter) ConnectionID() *MockBrokerCoreService_ConnectionID_Call {
2288+ return &MockBrokerCoreService_ConnectionID_Call{Call: _e.mock.On("ConnectionID")}
4982289 }
4992290
500-func (_c *MockBrokerService_ConnectionID_Call) Run(run func()) *MockBrokerService_ConnectionID_Call {
2291+func (_c *MockBrokerCoreService_ConnectionID_Call) Run(run func()) *MockBrokerCoreService_ConnectionID_Call {
5012292 _c.Call.Run(func(args mock.Arguments) {
5022293 run()
5032294 })
5042295 return _c
5052296 }
5062297
507-func (_c *MockBrokerService_ConnectionID_Call) Return(brokerConnectionID ports.BrokerConnectionID) *MockBrokerService_ConnectionID_Call {
2298+func (_c *MockBrokerCoreService_ConnectionID_Call) Return(brokerConnectionID ports.BrokerConnectionID) *MockBrokerCoreService_ConnectionID_Call {
5082299 _c.Call.Return(brokerConnectionID)
5092300 return _c
5102301 }
5112302
512-func (_c *MockBrokerService_ConnectionID_Call) RunAndReturn(run func() ports.BrokerConnectionID) *MockBrokerService_ConnectionID_Call {
2303+func (_c *MockBrokerCoreService_ConnectionID_Call) RunAndReturn(run func() ports.BrokerConnectionID) *MockBrokerCoreService_ConnectionID_Call {
5132304 _c.Call.Return(run)
5142305 return _c
5152306 }
5162307
517-// Done provides a mock function for the type MockBrokerService
518-func (_mock *MockBrokerService) Done() <-chan struct{} {
2308+// Done provides a mock function for the type MockBrokerCoreService
2309+func (_mock *MockBrokerCoreService) Done() <-chan struct{} {
5192310 ret := _mock.Called()
5202311
5212312 if len(ret) == 0 {
@@ -533,35 +2324,35 @@ func (_mock *MockBrokerService) Done() <-chan struct{} {
5332324 return r0
5342325 }
5352326
536-// MockBrokerService_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done'
537-type MockBrokerService_Done_Call struct {
2327+// MockBrokerCoreService_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done'
2328+type MockBrokerCoreService_Done_Call struct {
5382329 *mock.Call
5392330 }
5402331
5412332 // Done is a helper method to define mock.On call
542-func (_e *MockBrokerService_Expecter) Done() *MockBrokerService_Done_Call {
543- return &MockBrokerService_Done_Call{Call: _e.mock.On("Done")}
2333+func (_e *MockBrokerCoreService_Expecter) Done() *MockBrokerCoreService_Done_Call {
2334+ return &MockBrokerCoreService_Done_Call{Call: _e.mock.On("Done")}
5442335 }
5452336
546-func (_c *MockBrokerService_Done_Call) Run(run func()) *MockBrokerService_Done_Call {
2337+func (_c *MockBrokerCoreService_Done_Call) Run(run func()) *MockBrokerCoreService_Done_Call {
5472338 _c.Call.Run(func(args mock.Arguments) {
5482339 run()
5492340 })
5502341 return _c
5512342 }
5522343
553-func (_c *MockBrokerService_Done_Call) Return(valCh <-chan struct{}) *MockBrokerService_Done_Call {
2344+func (_c *MockBrokerCoreService_Done_Call) Return(valCh <-chan struct{}) *MockBrokerCoreService_Done_Call {
5542345 _c.Call.Return(valCh)
5552346 return _c
5562347 }
5572348
558-func (_c *MockBrokerService_Done_Call) RunAndReturn(run func() <-chan struct{}) *MockBrokerService_Done_Call {
2349+func (_c *MockBrokerCoreService_Done_Call) RunAndReturn(run func() <-chan struct{}) *MockBrokerCoreService_Done_Call {
5592350 _c.Call.Return(run)
5602351 return _c
5612352 }
5622353
563-// Err provides a mock function for the type MockBrokerService
564-func (_mock *MockBrokerService) Err() error {
2354+// Err provides a mock function for the type MockBrokerCoreService
2355+func (_mock *MockBrokerCoreService) Err() error {
5652356 ret := _mock.Called()
5662357
5672358 if len(ret) == 0 {
@@ -577,35 +2368,35 @@ func (_mock *MockBrokerService) Err() error {
5772368 return r0
5782369 }
5792370
580-// MockBrokerService_Err_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Err'
581-type MockBrokerService_Err_Call struct {
2371+// MockBrokerCoreService_Err_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Err'
2372+type MockBrokerCoreService_Err_Call struct {
5822373 *mock.Call
5832374 }
5842375
5852376 // Err is a helper method to define mock.On call
586-func (_e *MockBrokerService_Expecter) Err() *MockBrokerService_Err_Call {
587- return &MockBrokerService_Err_Call{Call: _e.mock.On("Err")}
2377+func (_e *MockBrokerCoreService_Expecter) Err() *MockBrokerCoreService_Err_Call {
2378+ return &MockBrokerCoreService_Err_Call{Call: _e.mock.On("Err")}
5882379 }
5892380
590-func (_c *MockBrokerService_Err_Call) Run(run func()) *MockBrokerService_Err_Call {
2381+func (_c *MockBrokerCoreService_Err_Call) Run(run func()) *MockBrokerCoreService_Err_Call {
5912382 _c.Call.Run(func(args mock.Arguments) {
5922383 run()
5932384 })
5942385 return _c
5952386 }
5962387
597-func (_c *MockBrokerService_Err_Call) Return(err error) *MockBrokerService_Err_Call {
2388+func (_c *MockBrokerCoreService_Err_Call) Return(err error) *MockBrokerCoreService_Err_Call {
5982389 _c.Call.Return(err)
5992390 return _c
6002391 }
6012392
602-func (_c *MockBrokerService_Err_Call) RunAndReturn(run func() error) *MockBrokerService_Err_Call {
2393+func (_c *MockBrokerCoreService_Err_Call) RunAndReturn(run func() error) *MockBrokerCoreService_Err_Call {
6032394 _c.Call.Return(run)
6042395 return _c
6052396 }
6062397
607-// NextStreamID provides a mock function for the type MockBrokerService
608-func (_mock *MockBrokerService) NextStreamID() (ports.BrokerStreamID, error) {
2398+// NextStreamID provides a mock function for the type MockBrokerCoreService
2399+func (_mock *MockBrokerCoreService) NextStreamID() (ports.BrokerStreamID, error) {
6092400 ret := _mock.Called()
6102401
6112402 if len(ret) == 0 {
@@ -630,51 +2421,51 @@ func (_mock *MockBrokerService) NextStreamID() (ports.BrokerStreamID, error) {
6302421 return r0, r1
6312422 }
6322423
633-// MockBrokerService_NextStreamID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextStreamID'
634-type MockBrokerService_NextStreamID_Call struct {
2424+// MockBrokerCoreService_NextStreamID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextStreamID'
2425+type MockBrokerCoreService_NextStreamID_Call struct {
6352426 *mock.Call
6362427 }
6372428
6382429 // NextStreamID is a helper method to define mock.On call
639-func (_e *MockBrokerService_Expecter) NextStreamID() *MockBrokerService_NextStreamID_Call {
640- return &MockBrokerService_NextStreamID_Call{Call: _e.mock.On("NextStreamID")}
2430+func (_e *MockBrokerCoreService_Expecter) NextStreamID() *MockBrokerCoreService_NextStreamID_Call {
2431+ return &MockBrokerCoreService_NextStreamID_Call{Call: _e.mock.On("NextStreamID")}
6412432 }
6422433
643-func (_c *MockBrokerService_NextStreamID_Call) Run(run func()) *MockBrokerService_NextStreamID_Call {
2434+func (_c *MockBrokerCoreService_NextStreamID_Call) Run(run func()) *MockBrokerCoreService_NextStreamID_Call {
6442435 _c.Call.Run(func(args mock.Arguments) {
6452436 run()
6462437 })
6472438 return _c
6482439 }
6492440
650-func (_c *MockBrokerService_NextStreamID_Call) Return(brokerStreamID ports.BrokerStreamID, err error) *MockBrokerService_NextStreamID_Call {
2441+func (_c *MockBrokerCoreService_NextStreamID_Call) Return(brokerStreamID ports.BrokerStreamID, err error) *MockBrokerCoreService_NextStreamID_Call {
6512442 _c.Call.Return(brokerStreamID, err)
6522443 return _c
6532444 }
6542445
655-func (_c *MockBrokerService_NextStreamID_Call) RunAndReturn(run func() (ports.BrokerStreamID, error)) *MockBrokerService_NextStreamID_Call {
2446+func (_c *MockBrokerCoreService_NextStreamID_Call) RunAndReturn(run func() (ports.BrokerStreamID, error)) *MockBrokerCoreService_NextStreamID_Call {
6562447 _c.Call.Return(run)
6572448 return _c
6582449 }
6592450
660-// OpenStream provides a mock function for the type MockBrokerService
661-func (_mock *MockBrokerService) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
2451+// OpenEnvelopeStream provides a mock function for the type MockBrokerCoreService
2452+func (_mock *MockBrokerCoreService) OpenEnvelopeStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
6622453 ret := _mock.Called(ctx, request)
6632454
6642455 if len(ret) == 0 {
665- panic("no return value specified for OpenStream")
2456+ panic("no return value specified for OpenEnvelopeStream")
6662457 }
6672458
668- var r0 ports.BrokerLogicalConnection
2459+ var r0 ports.BrokerEnvelopeStream
6692460 var r1 error
670- if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error)); ok {
2461+ if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error)); ok {
6712462 return returnFunc(ctx, request)
6722463 }
673- if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) ports.BrokerLogicalConnection); ok {
2464+ if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) ports.BrokerEnvelopeStream); ok {
6742465 r0 = returnFunc(ctx, request)
6752466 } else {
6762467 if ret.Get(0) != nil {
677- r0 = ret.Get(0).(ports.BrokerLogicalConnection)
2468+ r0 = ret.Get(0).(ports.BrokerEnvelopeStream)
6782469 }
6792470 }
6802471 if returnFunc, ok := ret.Get(1).(func(context.Context, ports.BrokerOpenStreamRequest) error); ok {
@@ -685,19 +2476,19 @@ func (_mock *MockBrokerService) OpenStream(ctx context.Context, request ports.Br
6852476 return r0, r1
6862477 }
6872478
688-// MockBrokerService_OpenStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OpenStream'
689-type MockBrokerService_OpenStream_Call struct {
2479+// MockBrokerCoreService_OpenEnvelopeStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OpenEnvelopeStream'
2480+type MockBrokerCoreService_OpenEnvelopeStream_Call struct {
6902481 *mock.Call
6912482 }
6922483
693-// OpenStream is a helper method to define mock.On call
2484+// OpenEnvelopeStream is a helper method to define mock.On call
6942485 // - ctx context.Context
6952486 // - request ports.BrokerOpenStreamRequest
696-func (_e *MockBrokerService_Expecter) OpenStream(ctx any, request any) *MockBrokerService_OpenStream_Call {
697- return &MockBrokerService_OpenStream_Call{Call: _e.mock.On("OpenStream", ctx, request)}
2487+func (_e *MockBrokerCoreService_Expecter) OpenEnvelopeStream(ctx any, request any) *MockBrokerCoreService_OpenEnvelopeStream_Call {
2488+ return &MockBrokerCoreService_OpenEnvelopeStream_Call{Call: _e.mock.On("OpenEnvelopeStream", ctx, request)}
6982489 }
6992490
700-func (_c *MockBrokerService_OpenStream_Call) Run(run func(ctx context.Context, request ports.BrokerOpenStreamRequest)) *MockBrokerService_OpenStream_Call {
2491+func (_c *MockBrokerCoreService_OpenEnvelopeStream_Call) Run(run func(ctx context.Context, request ports.BrokerOpenStreamRequest)) *MockBrokerCoreService_OpenEnvelopeStream_Call {
7012492 _c.Call.Run(func(args mock.Arguments) {
7022493 var arg0 context.Context
7032494 if args[0] != nil {
@@ -715,18 +2506,18 @@ func (_c *MockBrokerService_OpenStream_Call) Run(run func(ctx context.Context, r
7152506 return _c
7162507 }
7172508
718-func (_c *MockBrokerService_OpenStream_Call) Return(brokerLogicalConnection ports.BrokerLogicalConnection, err error) *MockBrokerService_OpenStream_Call {
719- _c.Call.Return(brokerLogicalConnection, err)
2509+func (_c *MockBrokerCoreService_OpenEnvelopeStream_Call) Return(brokerEnvelopeStream ports.BrokerEnvelopeStream, err error) *MockBrokerCoreService_OpenEnvelopeStream_Call {
2510+ _c.Call.Return(brokerEnvelopeStream, err)
7202511 return _c
7212512 }
7222513
723-func (_c *MockBrokerService_OpenStream_Call) RunAndReturn(run func(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error)) *MockBrokerService_OpenStream_Call {
2514+func (_c *MockBrokerCoreService_OpenEnvelopeStream_Call) RunAndReturn(run func(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error)) *MockBrokerCoreService_OpenEnvelopeStream_Call {
7242515 _c.Call.Return(run)
7252516 return _c
7262517 }
7272518
728-// RemoveHost provides a mock function for the type MockBrokerService
729-func (_mock *MockBrokerService) RemoveHost(ctx context.Context, expected domain.RemoteRegistration) (bool, error) {
2519+// RemoveHost provides a mock function for the type MockBrokerCoreService
2520+func (_mock *MockBrokerCoreService) RemoveHost(ctx context.Context, expected domain.RemoteRegistration) (bool, error) {
7302521 ret := _mock.Called(ctx, expected)
7312522
7322523 if len(ret) == 0 {
@@ -751,19 +2542,19 @@ func (_mock *MockBrokerService) RemoveHost(ctx context.Context, expected domain.
7512542 return r0, r1
7522543 }
7532544
754-// MockBrokerService_RemoveHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveHost'
755-type MockBrokerService_RemoveHost_Call struct {
2545+// MockBrokerCoreService_RemoveHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveHost'
2546+type MockBrokerCoreService_RemoveHost_Call struct {
7562547 *mock.Call
7572548 }
7582549
7592550 // RemoveHost is a helper method to define mock.On call
7602551 // - ctx context.Context
7612552 // - expected domain.RemoteRegistration
762-func (_e *MockBrokerService_Expecter) RemoveHost(ctx any, expected any) *MockBrokerService_RemoveHost_Call {
763- return &MockBrokerService_RemoveHost_Call{Call: _e.mock.On("RemoveHost", ctx, expected)}
2553+func (_e *MockBrokerCoreService_Expecter) RemoveHost(ctx any, expected any) *MockBrokerCoreService_RemoveHost_Call {
2554+ return &MockBrokerCoreService_RemoveHost_Call{Call: _e.mock.On("RemoveHost", ctx, expected)}
7642555 }
7652556
766-func (_c *MockBrokerService_RemoveHost_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration)) *MockBrokerService_RemoveHost_Call {
2557+func (_c *MockBrokerCoreService_RemoveHost_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration)) *MockBrokerCoreService_RemoveHost_Call {
7672558 _c.Call.Run(func(args mock.Arguments) {
7682559 var arg0 context.Context
7692560 if args[0] != nil {
@@ -781,34 +2572,34 @@ func (_c *MockBrokerService_RemoveHost_Call) Run(run func(ctx context.Context, e
7812572 return _c
7822573 }
7832574
784-func (_c *MockBrokerService_RemoveHost_Call) Return(b bool, err error) *MockBrokerService_RemoveHost_Call {
2575+func (_c *MockBrokerCoreService_RemoveHost_Call) Return(b bool, err error) *MockBrokerCoreService_RemoveHost_Call {
7852576 _c.Call.Return(b, err)
7862577 return _c
7872578 }
7882579
789-func (_c *MockBrokerService_RemoveHost_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration) (bool, error)) *MockBrokerService_RemoveHost_Call {
2580+func (_c *MockBrokerCoreService_RemoveHost_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration) (bool, error)) *MockBrokerCoreService_RemoveHost_Call {
7902581 _c.Call.Return(run)
7912582 return _c
7922583 }
7932584
794-// RequestReconcile provides a mock function for the type MockBrokerService
795-func (_mock *MockBrokerService) RequestReconcile(endpoint string) {
2585+// RequestReconcile provides a mock function for the type MockBrokerCoreService
2586+func (_mock *MockBrokerCoreService) RequestReconcile(endpoint string) {
7962587 _mock.Called(endpoint)
7972588 return
7982589 }
7992590
800-// MockBrokerService_RequestReconcile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestReconcile'
801-type MockBrokerService_RequestReconcile_Call struct {
2591+// MockBrokerCoreService_RequestReconcile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestReconcile'
2592+type MockBrokerCoreService_RequestReconcile_Call struct {
8022593 *mock.Call
8032594 }
8042595
8052596 // RequestReconcile is a helper method to define mock.On call
8062597 // - endpoint string
807-func (_e *MockBrokerService_Expecter) RequestReconcile(endpoint any) *MockBrokerService_RequestReconcile_Call {
808- return &MockBrokerService_RequestReconcile_Call{Call: _e.mock.On("RequestReconcile", endpoint)}
2598+func (_e *MockBrokerCoreService_Expecter) RequestReconcile(endpoint any) *MockBrokerCoreService_RequestReconcile_Call {
2599+ return &MockBrokerCoreService_RequestReconcile_Call{Call: _e.mock.On("RequestReconcile", endpoint)}
8092600 }
8102601
811-func (_c *MockBrokerService_RequestReconcile_Call) Run(run func(endpoint string)) *MockBrokerService_RequestReconcile_Call {
2602+func (_c *MockBrokerCoreService_RequestReconcile_Call) Run(run func(endpoint string)) *MockBrokerCoreService_RequestReconcile_Call {
8122603 _c.Call.Run(func(args mock.Arguments) {
8132604 var arg0 string
8142605 if args[0] != nil {
@@ -821,18 +2612,18 @@ func (_c *MockBrokerService_RequestReconcile_Call) Run(run func(endpoint string)
8212612 return _c
8222613 }
8232614
824-func (_c *MockBrokerService_RequestReconcile_Call) Return() *MockBrokerService_RequestReconcile_Call {
2615+func (_c *MockBrokerCoreService_RequestReconcile_Call) Return() *MockBrokerCoreService_RequestReconcile_Call {
8252616 _c.Call.Return()
8262617 return _c
8272618 }
8282619
829-func (_c *MockBrokerService_RequestReconcile_Call) RunAndReturn(run func(endpoint string)) *MockBrokerService_RequestReconcile_Call {
2620+func (_c *MockBrokerCoreService_RequestReconcile_Call) RunAndReturn(run func(endpoint string)) *MockBrokerCoreService_RequestReconcile_Call {
8302621 _c.Run(run)
8312622 return _c
8322623 }
8332624
834-// Snapshot provides a mock function for the type MockBrokerService
835-func (_mock *MockBrokerService) Snapshot() ports.BrokerSnapshot {
2625+// Snapshot provides a mock function for the type MockBrokerCoreService
2626+func (_mock *MockBrokerCoreService) Snapshot() ports.BrokerSnapshot {
8362627 ret := _mock.Called()
8372628
8382629 if len(ret) == 0 {
@@ -848,35 +2639,35 @@ func (_mock *MockBrokerService) Snapshot() ports.BrokerSnapshot {
8482639 return r0
8492640 }
8502641
851-// MockBrokerService_Snapshot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Snapshot'
852-type MockBrokerService_Snapshot_Call struct {
2642+// MockBrokerCoreService_Snapshot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Snapshot'
2643+type MockBrokerCoreService_Snapshot_Call struct {
8532644 *mock.Call
8542645 }
8552646
8562647 // Snapshot is a helper method to define mock.On call
857-func (_e *MockBrokerService_Expecter) Snapshot() *MockBrokerService_Snapshot_Call {
858- return &MockBrokerService_Snapshot_Call{Call: _e.mock.On("Snapshot")}
2648+func (_e *MockBrokerCoreService_Expecter) Snapshot() *MockBrokerCoreService_Snapshot_Call {
2649+ return &MockBrokerCoreService_Snapshot_Call{Call: _e.mock.On("Snapshot")}
8592650 }
8602651
861-func (_c *MockBrokerService_Snapshot_Call) Run(run func()) *MockBrokerService_Snapshot_Call {
2652+func (_c *MockBrokerCoreService_Snapshot_Call) Run(run func()) *MockBrokerCoreService_Snapshot_Call {
8622653 _c.Call.Run(func(args mock.Arguments) {
8632654 run()
8642655 })
8652656 return _c
8662657 }
8672658
868-func (_c *MockBrokerService_Snapshot_Call) Return(brokerSnapshot ports.BrokerSnapshot) *MockBrokerService_Snapshot_Call {
2659+func (_c *MockBrokerCoreService_Snapshot_Call) Return(brokerSnapshot ports.BrokerSnapshot) *MockBrokerCoreService_Snapshot_Call {
8692660 _c.Call.Return(brokerSnapshot)
8702661 return _c
8712662 }
8722663
873-func (_c *MockBrokerService_Snapshot_Call) RunAndReturn(run func() ports.BrokerSnapshot) *MockBrokerService_Snapshot_Call {
2664+func (_c *MockBrokerCoreService_Snapshot_Call) RunAndReturn(run func() ports.BrokerSnapshot) *MockBrokerCoreService_Snapshot_Call {
8742665 _c.Call.Return(run)
8752666 return _c
8762667 }
8772668
878-// Subscribe provides a mock function for the type MockBrokerService
879-func (_mock *MockBrokerService) Subscribe() (ports.BrokerSubscription, error) {
2669+// Subscribe provides a mock function for the type MockBrokerCoreService
2670+func (_mock *MockBrokerCoreService) Subscribe() (ports.BrokerSubscription, error) {
8802671 ret := _mock.Called()
8812672
8822673 if len(ret) == 0 {
@@ -903,35 +2694,35 @@ func (_mock *MockBrokerService) Subscribe() (ports.BrokerSubscription, error) {
9032694 return r0, r1
9042695 }
9052696
906-// MockBrokerService_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe'
907-type MockBrokerService_Subscribe_Call struct {
2697+// MockBrokerCoreService_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe'
2698+type MockBrokerCoreService_Subscribe_Call struct {
9082699 *mock.Call
9092700 }
9102701
9112702 // Subscribe is a helper method to define mock.On call
912-func (_e *MockBrokerService_Expecter) Subscribe() *MockBrokerService_Subscribe_Call {
913- return &MockBrokerService_Subscribe_Call{Call: _e.mock.On("Subscribe")}
2703+func (_e *MockBrokerCoreService_Expecter) Subscribe() *MockBrokerCoreService_Subscribe_Call {
2704+ return &MockBrokerCoreService_Subscribe_Call{Call: _e.mock.On("Subscribe")}
9142705 }
9152706
916-func (_c *MockBrokerService_Subscribe_Call) Run(run func()) *MockBrokerService_Subscribe_Call {
2707+func (_c *MockBrokerCoreService_Subscribe_Call) Run(run func()) *MockBrokerCoreService_Subscribe_Call {
9172708 _c.Call.Run(func(args mock.Arguments) {
9182709 run()
9192710 })
9202711 return _c
9212712 }
9222713
923-func (_c *MockBrokerService_Subscribe_Call) Return(brokerSubscription ports.BrokerSubscription, err error) *MockBrokerService_Subscribe_Call {
2714+func (_c *MockBrokerCoreService_Subscribe_Call) Return(brokerSubscription ports.BrokerSubscription, err error) *MockBrokerCoreService_Subscribe_Call {
9242715 _c.Call.Return(brokerSubscription, err)
9252716 return _c
9262717 }
9272718
928-func (_c *MockBrokerService_Subscribe_Call) RunAndReturn(run func() (ports.BrokerSubscription, error)) *MockBrokerService_Subscribe_Call {
2719+func (_c *MockBrokerCoreService_Subscribe_Call) RunAndReturn(run func() (ports.BrokerSubscription, error)) *MockBrokerCoreService_Subscribe_Call {
9292720 _c.Call.Return(run)
9302721 return _c
9312722 }
9322723
933-// SubscribePreview provides a mock function for the type MockBrokerService
934-func (_mock *MockBrokerService) SubscribePreview(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error) {
2724+// SubscribePreview provides a mock function for the type MockBrokerCoreService
2725+func (_mock *MockBrokerCoreService) SubscribePreview(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error) {
9352726 ret := _mock.Called(request)
9362727
9372728 if len(ret) == 0 {
@@ -958,18 +2749,18 @@ func (_mock *MockBrokerService) SubscribePreview(request ports.BrokerPreviewRequ
9582749 return r0, r1
9592750 }
9602751
961-// MockBrokerService_SubscribePreview_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribePreview'
962-type MockBrokerService_SubscribePreview_Call struct {
2752+// MockBrokerCoreService_SubscribePreview_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribePreview'
2753+type MockBrokerCoreService_SubscribePreview_Call struct {
9632754 *mock.Call
9642755 }
9652756
9662757 // SubscribePreview is a helper method to define mock.On call
9672758 // - request ports.BrokerPreviewRequest
968-func (_e *MockBrokerService_Expecter) SubscribePreview(request any) *MockBrokerService_SubscribePreview_Call {
969- return &MockBrokerService_SubscribePreview_Call{Call: _e.mock.On("SubscribePreview", request)}
2759+func (_e *MockBrokerCoreService_Expecter) SubscribePreview(request any) *MockBrokerCoreService_SubscribePreview_Call {
2760+ return &MockBrokerCoreService_SubscribePreview_Call{Call: _e.mock.On("SubscribePreview", request)}
9702761 }
9712762
972-func (_c *MockBrokerService_SubscribePreview_Call) Run(run func(request ports.BrokerPreviewRequest)) *MockBrokerService_SubscribePreview_Call {
2763+func (_c *MockBrokerCoreService_SubscribePreview_Call) Run(run func(request ports.BrokerPreviewRequest)) *MockBrokerCoreService_SubscribePreview_Call {
9732764 _c.Call.Run(func(args mock.Arguments) {
9742765 var arg0 ports.BrokerPreviewRequest
9752766 if args[0] != nil {
@@ -982,18 +2773,18 @@ func (_c *MockBrokerService_SubscribePreview_Call) Run(run func(request ports.Br
9822773 return _c
9832774 }
9842775
985-func (_c *MockBrokerService_SubscribePreview_Call) Return(brokerPreviewSubscription ports.BrokerPreviewSubscription, err error) *MockBrokerService_SubscribePreview_Call {
2776+func (_c *MockBrokerCoreService_SubscribePreview_Call) Return(brokerPreviewSubscription ports.BrokerPreviewSubscription, err error) *MockBrokerCoreService_SubscribePreview_Call {
9862777 _c.Call.Return(brokerPreviewSubscription, err)
9872778 return _c
9882779 }
9892780
990-func (_c *MockBrokerService_SubscribePreview_Call) RunAndReturn(run func(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error)) *MockBrokerService_SubscribePreview_Call {
2781+func (_c *MockBrokerCoreService_SubscribePreview_Call) RunAndReturn(run func(request ports.BrokerPreviewRequest) (ports.BrokerPreviewSubscription, error)) *MockBrokerCoreService_SubscribePreview_Call {
9912782 _c.Call.Return(run)
9922783 return _c
9932784 }
9942785
995-// UpdateHostPolicy provides a mock function for the type MockBrokerService
996-func (_mock *MockBrokerService) UpdateHostPolicy(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
2786+// UpdateHostPolicy provides a mock function for the type MockBrokerCoreService
2787+func (_mock *MockBrokerCoreService) UpdateHostPolicy(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error) {
9972788 ret := _mock.Called(ctx, expected, policy)
9982789
9992790 if len(ret) == 0 {
@@ -1018,8 +2809,8 @@ func (_mock *MockBrokerService) UpdateHostPolicy(ctx context.Context, expected d
10182809 return r0, r1
10192810 }
10202811
1021-// MockBrokerService_UpdateHostPolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateHostPolicy'
1022-type MockBrokerService_UpdateHostPolicy_Call struct {
2812+// MockBrokerCoreService_UpdateHostPolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateHostPolicy'
2813+type MockBrokerCoreService_UpdateHostPolicy_Call struct {
10232814 *mock.Call
10242815 }
10252816
@@ -1027,11 +2818,11 @@ type MockBrokerService_UpdateHostPolicy_Call struct {
10272818 // - ctx context.Context
10282819 // - expected domain.RemoteRegistration
10292820 // - policy ports.BrokerPolicy
1030-func (_e *MockBrokerService_Expecter) UpdateHostPolicy(ctx any, expected any, policy any) *MockBrokerService_UpdateHostPolicy_Call {
1031- return &MockBrokerService_UpdateHostPolicy_Call{Call: _e.mock.On("UpdateHostPolicy", ctx, expected, policy)}
2821+func (_e *MockBrokerCoreService_Expecter) UpdateHostPolicy(ctx any, expected any, policy any) *MockBrokerCoreService_UpdateHostPolicy_Call {
2822+ return &MockBrokerCoreService_UpdateHostPolicy_Call{Call: _e.mock.On("UpdateHostPolicy", ctx, expected, policy)}
10322823 }
10332824
1034-func (_c *MockBrokerService_UpdateHostPolicy_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy)) *MockBrokerService_UpdateHostPolicy_Call {
2825+func (_c *MockBrokerCoreService_UpdateHostPolicy_Call) Run(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy)) *MockBrokerCoreService_UpdateHostPolicy_Call {
10352826 _c.Call.Run(func(args mock.Arguments) {
10362827 var arg0 context.Context
10372828 if args[0] != nil {
@@ -1054,12 +2845,92 @@ func (_c *MockBrokerService_UpdateHostPolicy_Call) Run(run func(ctx context.Cont
10542845 return _c
10552846 }
10562847
1057-func (_c *MockBrokerService_UpdateHostPolicy_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerService_UpdateHostPolicy_Call {
2848+func (_c *MockBrokerCoreService_UpdateHostPolicy_Call) Return(remoteRegistration domain.RemoteRegistration, err error) *MockBrokerCoreService_UpdateHostPolicy_Call {
10582849 _c.Call.Return(remoteRegistration, err)
10592850 return _c
10602851 }
10612852
1062-func (_c *MockBrokerService_UpdateHostPolicy_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerService_UpdateHostPolicy_Call {
2853+func (_c *MockBrokerCoreService_UpdateHostPolicy_Call) RunAndReturn(run func(ctx context.Context, expected domain.RemoteRegistration, policy ports.BrokerPolicy) (domain.RemoteRegistration, error)) *MockBrokerCoreService_UpdateHostPolicy_Call {
2854+ _c.Call.Return(run)
2855+ return _c
2856+}
2857+
2858+// NewMockSessionCodec creates a new instance of MockSessionCodec. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
2859+// The first argument is typically a *testing.T value.
2860+func NewMockSessionCodec(t interface {
2861+ mock.TestingT
2862+ Cleanup(func())
2863+}) *MockSessionCodec {
2864+ mock := &MockSessionCodec{}
2865+ mock.Mock.Test(t)
2866+
2867+ t.Cleanup(func() { mock.AssertExpectations(t) })
2868+
2869+ return mock
2870+}
2871+
2872+// MockSessionCodec is an autogenerated mock type for the SessionCodec type
2873+type MockSessionCodec struct {
2874+ mock.Mock
2875+}
2876+
2877+type MockSessionCodec_Expecter struct {
2878+ mock *mock.Mock
2879+}
2880+
2881+func (_m *MockSessionCodec) EXPECT() *MockSessionCodec_Expecter {
2882+ return &MockSessionCodec_Expecter{mock: &_m.Mock}
2883+}
2884+
2885+// Client provides a mock function for the type MockSessionCodec
2886+func (_mock *MockSessionCodec) Client(brokerEnvelopeStream ports.BrokerEnvelopeStream) ports.ClientConnection {
2887+ ret := _mock.Called(brokerEnvelopeStream)
2888+
2889+ if len(ret) == 0 {
2890+ panic("no return value specified for Client")
2891+ }
2892+
2893+ var r0 ports.ClientConnection
2894+ if returnFunc, ok := ret.Get(0).(func(ports.BrokerEnvelopeStream) ports.ClientConnection); ok {
2895+ r0 = returnFunc(brokerEnvelopeStream)
2896+ } else {
2897+ if ret.Get(0) != nil {
2898+ r0 = ret.Get(0).(ports.ClientConnection)
2899+ }
2900+ }
2901+ return r0
2902+}
2903+
2904+// MockSessionCodec_Client_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Client'
2905+type MockSessionCodec_Client_Call struct {
2906+ *mock.Call
2907+}
2908+
2909+// Client is a helper method to define mock.On call
2910+// - brokerEnvelopeStream ports.BrokerEnvelopeStream
2911+func (_e *MockSessionCodec_Expecter) Client(brokerEnvelopeStream any) *MockSessionCodec_Client_Call {
2912+ return &MockSessionCodec_Client_Call{Call: _e.mock.On("Client", brokerEnvelopeStream)}
2913+}
2914+
2915+func (_c *MockSessionCodec_Client_Call) Run(run func(brokerEnvelopeStream ports.BrokerEnvelopeStream)) *MockSessionCodec_Client_Call {
2916+ _c.Call.Run(func(args mock.Arguments) {
2917+ var arg0 ports.BrokerEnvelopeStream
2918+ if args[0] != nil {
2919+ arg0 = args[0].(ports.BrokerEnvelopeStream)
2920+ }
2921+ run(
2922+ arg0,
2923+ )
2924+ })
2925+ return _c
2926+}
2927+
2928+func (_c *MockSessionCodec_Client_Call) Return(clientConnection ports.ClientConnection) *MockSessionCodec_Client_Call {
2929+ _c.Call.Return(clientConnection)
2930+ return _c
2931+}
2932+
2933+func (_c *MockSessionCodec_Client_Call) RunAndReturn(run func(brokerEnvelopeStream ports.BrokerEnvelopeStream) ports.ClientConnection) *MockSessionCodec_Client_Call {
10632934 _c.Call.Return(run)
10642935 return _c
10652936 }
@@ -1584,23 +3455,23 @@ func (_c *MockBrokerPhysicalConnection_Incarnation_Call) RunAndReturn(run func()
15843455 }
15853456
15863457 // OpenStream provides a mock function for the type MockBrokerPhysicalConnection
1587-func (_mock *MockBrokerPhysicalConnection) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
3458+func (_mock *MockBrokerPhysicalConnection) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
15883459 ret := _mock.Called(ctx, request)
15893460
15903461 if len(ret) == 0 {
15913462 panic("no return value specified for OpenStream")
15923463 }
15933464
1594- var r0 ports.BrokerLogicalConnection
3465+ var r0 ports.BrokerEnvelopeStream
15953466 var r1 error
1596- if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error)); ok {
3467+ if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error)); ok {
15973468 return returnFunc(ctx, request)
15983469 }
1599- if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) ports.BrokerLogicalConnection); ok {
3470+ if returnFunc, ok := ret.Get(0).(func(context.Context, ports.BrokerOpenStreamRequest) ports.BrokerEnvelopeStream); ok {
16003471 r0 = returnFunc(ctx, request)
16013472 } else {
16023473 if ret.Get(0) != nil {
1603- r0 = ret.Get(0).(ports.BrokerLogicalConnection)
3474+ r0 = ret.Get(0).(ports.BrokerEnvelopeStream)
16043475 }
16053476 }
16063477 if returnFunc, ok := ret.Get(1).(func(context.Context, ports.BrokerOpenStreamRequest) error); ok {
@@ -1641,12 +3512,12 @@ func (_c *MockBrokerPhysicalConnection_OpenStream_Call) Run(run func(ctx context
16413512 return _c
16423513 }
16433514
1644-func (_c *MockBrokerPhysicalConnection_OpenStream_Call) Return(brokerLogicalConnection ports.BrokerLogicalConnection, err error) *MockBrokerPhysicalConnection_OpenStream_Call {
1645- _c.Call.Return(brokerLogicalConnection, err)
3515+func (_c *MockBrokerPhysicalConnection_OpenStream_Call) Return(brokerEnvelopeStream ports.BrokerEnvelopeStream, err error) *MockBrokerPhysicalConnection_OpenStream_Call {
3516+ _c.Call.Return(brokerEnvelopeStream, err)
16463517 return _c
16473518 }
16483519
1649-func (_c *MockBrokerPhysicalConnection_OpenStream_Call) RunAndReturn(run func(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error)) *MockBrokerPhysicalConnection_OpenStream_Call {
3520+func (_c *MockBrokerPhysicalConnection_OpenStream_Call) RunAndReturn(run func(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error)) *MockBrokerPhysicalConnection_OpenStream_Call {
16503521 _c.Call.Return(run)
16513522 return _c
16523523 }
@@ -1907,23 +3778,23 @@ func (_m *MockBrokerAuthority) EXPECT() *MockBrokerAuthority_Expecter {
19073778 }
19083779
19093780 // AdmitClient provides a mock function for the type MockBrokerAuthority
1910-func (_mock *MockBrokerAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) {
3781+func (_mock *MockBrokerAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) {
19113782 ret := _mock.Called(ctx)
19123783
19133784 if len(ret) == 0 {
19143785 panic("no return value specified for AdmitClient")
19153786 }
19163787
1917- var r0 ports.BrokerService
3788+ var r0 ports.BrokerCoreService
19183789 var r1 error
1919- if returnFunc, ok := ret.Get(0).(func(context.Context) (ports.BrokerService, error)); ok {
3790+ if returnFunc, ok := ret.Get(0).(func(context.Context) (ports.BrokerCoreService, error)); ok {
19203791 return returnFunc(ctx)
19213792 }
1922- if returnFunc, ok := ret.Get(0).(func(context.Context) ports.BrokerService); ok {
3793+ if returnFunc, ok := ret.Get(0).(func(context.Context) ports.BrokerCoreService); ok {
19233794 r0 = returnFunc(ctx)
19243795 } else {
19253796 if ret.Get(0) != nil {
1926- r0 = ret.Get(0).(ports.BrokerService)
3797+ r0 = ret.Get(0).(ports.BrokerCoreService)
19273798 }
19283799 }
19293800 if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok {
@@ -1958,12 +3829,12 @@ func (_c *MockBrokerAuthority_AdmitClient_Call) Run(run func(ctx context.Context
19583829 return _c
19593830 }
19603831
1961-func (_c *MockBrokerAuthority_AdmitClient_Call) Return(brokerService ports.BrokerService, err error) *MockBrokerAuthority_AdmitClient_Call {
1962- _c.Call.Return(brokerService, err)
3832+func (_c *MockBrokerAuthority_AdmitClient_Call) Return(brokerCoreService ports.BrokerCoreService, err error) *MockBrokerAuthority_AdmitClient_Call {
3833+ _c.Call.Return(brokerCoreService, err)
19633834 return _c
19643835 }
19653836
1966-func (_c *MockBrokerAuthority_AdmitClient_Call) RunAndReturn(run func(ctx context.Context) (ports.BrokerService, error)) *MockBrokerAuthority_AdmitClient_Call {
3837+func (_c *MockBrokerAuthority_AdmitClient_Call) RunAndReturn(run func(ctx context.Context) (ports.BrokerCoreService, error)) *MockBrokerAuthority_AdmitClient_Call {
19673838 _c.Call.Return(run)
19683839 return _c
19693840 }
@@ -1996,23 +3867,23 @@ func (_m *MockBrokerListener) EXPECT() *MockBrokerListener_Expecter {
19963867 }
19973868
19983869 // Accept provides a mock function for the type MockBrokerListener
1999-func (_mock *MockBrokerListener) Accept() (ports.BrokerService, error) {
3870+func (_mock *MockBrokerListener) Accept() (ports.BrokerCoreService, error) {
20003871 ret := _mock.Called()
20013872
20023873 if len(ret) == 0 {
20033874 panic("no return value specified for Accept")
20043875 }
20053876
2006- var r0 ports.BrokerService
3877+ var r0 ports.BrokerCoreService
20073878 var r1 error
2008- if returnFunc, ok := ret.Get(0).(func() (ports.BrokerService, error)); ok {
3879+ if returnFunc, ok := ret.Get(0).(func() (ports.BrokerCoreService, error)); ok {
20093880 return returnFunc()
20103881 }
2011- if returnFunc, ok := ret.Get(0).(func() ports.BrokerService); ok {
3882+ if returnFunc, ok := ret.Get(0).(func() ports.BrokerCoreService); ok {
20123883 r0 = returnFunc()
20133884 } else {
20143885 if ret.Get(0) != nil {
2015- r0 = ret.Get(0).(ports.BrokerService)
3886+ r0 = ret.Get(0).(ports.BrokerCoreService)
20163887 }
20173888 }
20183889 if returnFunc, ok := ret.Get(1).(func() error); ok {
@@ -2040,12 +3911,12 @@ func (_c *MockBrokerListener_Accept_Call) Run(run func()) *MockBrokerListener_Ac
20403911 return _c
20413912 }
20423913
2043-func (_c *MockBrokerListener_Accept_Call) Return(brokerService ports.BrokerService, err error) *MockBrokerListener_Accept_Call {
2044- _c.Call.Return(brokerService, err)
3914+func (_c *MockBrokerListener_Accept_Call) Return(brokerCoreService ports.BrokerCoreService, err error) *MockBrokerListener_Accept_Call {
3915+ _c.Call.Return(brokerCoreService, err)
20453916 return _c
20463917 }
20473918
2048-func (_c *MockBrokerListener_Accept_Call) RunAndReturn(run func() (ports.BrokerService, error)) *MockBrokerListener_Accept_Call {
3919+func (_c *MockBrokerListener_Accept_Call) RunAndReturn(run func() (ports.BrokerCoreService, error)) *MockBrokerListener_Accept_Call {
20493920 _c.Call.Return(run)
20503921 return _c
20513922 }
M internal/usecase/broker/pool.go +4 -4
@@ -160,7 +160,7 @@ func (p *Pool) CloseStream(id ports.BrokerConnectionID, stream ports.BrokerStrea
160160 return nil
161161 }
162162
163-func (p *Pool) OpenStream(ctx context.Context, req ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
163+func (p *Pool) OpenStream(ctx context.Context, req ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
164164 if req.Epoch != p.epoch {
165165 return nil, ports.BrokerError{Code: ports.BrokerErrorStaleEpoch}
166166 }
@@ -324,7 +324,7 @@ func (p *Pool) OpenStream(ctx context.Context, req ports.BrokerOpenStreamRequest
324324 _ = raw.Close()
325325 return nil, terminal
326326 }
327- stream := &pooledStream{BrokerLogicalConnection: raw, done: make(chan struct{}), release: release}
327+ stream := &pooledStream{BrokerEnvelopeStream: raw, done: make(chan struct{}), release: release}
328328 success = true
329329 go func() {
330330 var terminal error
@@ -610,7 +610,7 @@ func (p *Pool) Close() error {
610610 }
611611
612612 type pooledStream struct {
613- ports.BrokerLogicalConnection
613+ ports.BrokerEnvelopeStream
614614 once sync.Once
615615 done chan struct{}
616616 err error
@@ -629,7 +629,7 @@ func (s *pooledStream) Err() error {
629629 }
630630 func (s *pooledStream) Close() error { s.finish(nil); return s.closeErr }
631631 func (s *pooledStream) finish(err error) {
632- s.once.Do(func() { s.err = err; s.closeErr = s.BrokerLogicalConnection.Close(); s.release(); close(s.done) })
632+ s.once.Do(func() { s.err = err; s.closeErr = s.BrokerEnvelopeStream.Close(); s.release(); close(s.done) })
633633 }
634634
635635 // One goroutine owns this timer. Drain a buffered expiry before every reset,
M internal/usecase/broker/pool_review_test.go +4 -4
@@ -28,7 +28,7 @@ func TestPoolAdapterFailures(t *testing.T) {
2828 if stage == "connector" {
2929 return nil, tc.err
3030 }
31- return &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
31+ return &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
3232 return nil, tc.err
3333 }}, nil
3434 })
@@ -52,7 +52,7 @@ func TestPoolRejectedPaths(t *testing.T) {
5252 for _, name := range []string{"closed", "epoch", "invalid endpoint", "nil raw", "retiring"} {
5353 t.Run(name, func(t *testing.T) {
5454 p, _ := setupPool(t, func(_ context.Context, e ports.BrokerDialTarget) (ports.BrokerPhysicalConnection, error) {
55- return &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
55+ return &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
5656 return nil, nil
5757 }}, nil
5858 })
@@ -125,7 +125,7 @@ func TestPoolPostOpenPhysicalLoss(t *testing.T) {
125125 raw := newFakeLogical()
126126 p, _ := setupPool(t, func(_ context.Context, e ports.BrokerDialTarget) (ports.BrokerPhysicalConnection, error) {
127127 f := &fakePhysical{endpoint: e, done: make(chan struct{})}
128- f.open = func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
128+ f.open = func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
129129 _ = f.Close()
130130 return raw, nil
131131 }
@@ -209,7 +209,7 @@ func (l *closeErrorLogical) Close() error { _ = l.fakeLogical.Close(); return l.
209209 func TestPooledStreamPreservesCloseError(t *testing.T) {
210210 cause := errors.New("close failed")
211211 calls := 0
212- s := &pooledStream{BrokerLogicalConnection: &closeErrorLogical{newFakeLogical(), cause}, done: make(chan struct{}), release: func() { calls++ }}
212+ s := &pooledStream{BrokerEnvelopeStream: &closeErrorLogical{newFakeLogical(), cause}, done: make(chan struct{}), release: func() { calls++ }}
213213 require.ErrorIs(t, s.Close(), cause)
214214 require.ErrorIs(t, s.Close(), cause)
215215 require.Equal(t, 1, calls)
M internal/usecase/broker/pool_test.go +13 -13
@@ -36,16 +36,16 @@ func (f poolConnector) Connect(c context.Context, r ports.BrokerDialTarget) (por
3636 }
3737
3838 type fakeLogical struct {
39- ports.ClientConnection
4039 done chan struct{}
4140 once sync.Once
4241 }
4342
44-func newFakeLogical() *fakeLogical { return &fakeLogical{done: make(chan struct{})} }
45-func (f *fakeLogical) Done() <-chan struct{} { return f.done }
46-func (f *fakeLogical) Err() error { return nil }
47-func (f *fakeLogical) Close() error { f.once.Do(func() { close(f.done) }); return nil }
48-func (f *fakeLogical) SendClient(protocol.ClientMessage) error { <-f.done; return errors.New("closed") }
43+func newFakeLogical() *fakeLogical { return &fakeLogical{done: make(chan struct{})} }
44+func (f *fakeLogical) Done() <-chan struct{} { return f.done }
45+func (f *fakeLogical) Err() error { return nil }
46+func (f *fakeLogical) Close() error { f.once.Do(func() { close(f.done) }); return nil }
47+func (f *fakeLogical) SendEnvelope([]byte) error { <-f.done; return errors.New("closed") }
48+func (f *fakeLogical) RecvEnvelope() ([]byte, error) { <-f.done; return nil, errors.New("closed") }
4949
5050 type fakePhysical struct {
5151 endpoint ports.BrokerDialTarget
@@ -54,7 +54,7 @@ type fakePhysical struct {
5454 identity ports.BrokerDaemonIdentity
5555 done chan struct{}
5656 once sync.Once
57- open func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error)
57+ open func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error)
5858 }
5959
6060 func (f *fakePhysical) Identity() ports.BrokerDaemonIdentity {
@@ -71,7 +71,7 @@ func (f *fakePhysical) FailureKind() domain.RemoteFailureKind { return domain.Re
7171 func (f *fakePhysical) Done() <-chan struct{} { return f.done }
7272 func (f *fakePhysical) Err() error { return errors.New("physical loss") }
7373 func (f *fakePhysical) Close() error { f.once.Do(func() { close(f.done) }); return nil }
74-func (f *fakePhysical) OpenStream(c context.Context, r ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
74+func (f *fakePhysical) OpenStream(c context.Context, r ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
7575 if f.open != nil {
7676 return f.open(c, r)
7777 }
@@ -140,7 +140,7 @@ func TestPoolOpenFailureWithTypedNilConnection(t *testing.T) {
140140 return &fakePhysical{
141141 endpoint: e,
142142 done: make(chan struct{}),
143- open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
143+ open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
144144 var absent *fakeLogical
145145 return absent, errors.New("open failed")
146146 },
@@ -164,7 +164,7 @@ func TestPoolHundredStreamsLossAndIsolation(t *testing.T) {
164164 physical = &fakePhysical{endpoint: e, done: make(chan struct{})}
165165 return physical, nil
166166 })
167- streams := make([]ports.BrokerLogicalConnection, 100)
167+ streams := make([]ports.BrokerEnvelopeStream, 100)
168168 var wg sync.WaitGroup
169169 for i := range streams {
170170 id, err := p.RegisterClient()
@@ -183,7 +183,7 @@ func TestPoolHundredStreamsLossAndIsolation(t *testing.T) {
183183 wg.Wait()
184184 require.EqualValues(t, 1, calls.Load())
185185 blocked := make(chan struct{})
186- go func() { _ = streams[0].SendClient(nil); close(blocked) }()
186+ go func() { _ = streams[0].SendEnvelope(nil); close(blocked) }()
187187 require.NoError(t, streams[0].Close())
188188 await(t, blocked)
189189 select {
@@ -336,7 +336,7 @@ func TestPoolCoalescedCancellation(t *testing.T) {
336336 result := make(chan error, 1)
337337 go func() { _, err := p.OpenStream(ctx, poolRequest(id1, 1)); result <- err }()
338338 await(t, entered)
339- result2 := make(chan ports.BrokerLogicalConnection, 1)
339+ result2 := make(chan ports.BrokerEnvelopeStream, 1)
340340 go func() {
341341 s, err := p.OpenStream(context.Background(), poolRequest(id2, 1))
342342 if err != nil {
@@ -475,7 +475,7 @@ func TestPoolAliasesAndPolicyPartition(t *testing.T) {
475475 func TestPoolPendingOpenCancellationDoesNotHoldLock(t *testing.T) {
476476 entered := make(chan struct{})
477477 p, _ := setupPool(t, func(_ context.Context, e ports.BrokerDialTarget) (ports.BrokerPhysicalConnection, error) {
478- return &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(ctx context.Context, r ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
478+ return &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(ctx context.Context, r ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
479479 if r.Stream == 1 {
480480 close(entered)
481481 <-ctx.Done()
M internal/usecase/broker/service.go +14 -11
@@ -12,7 +12,7 @@ import (
1212 // Offline broker composition.
1313 //
1414 // Authority admits one accepted client connection to the broker core and
15-// returns the connection-scoped ports.BrokerService for exactly that
15+// returns the connection-scoped ports.BrokerCoreService for exactly that
1616 // connection. It is the structural implementation of ports.BrokerAuthority,
1717 // the admission seam the broker IPC listener (internal/adapters/brokeripc)
1818 // consumes and which this use case must not import: admission obtains one
@@ -40,6 +40,7 @@ type Authority struct {
4040 pool *Pool
4141 supervisor *Supervisor
4242 clock ports.Clock
43+ codec ports.SessionCodec
4344 }
4445
4546 var _ ports.BrokerAuthority = (*Authority)(nil)
@@ -53,7 +54,7 @@ var _ ports.BrokerAuthority = (*Authority)(nil)
5354 // neither starts nor settles Run: serving connections without a live Run leaks
5455 // the writer and never flushes the newest staged publication, and a registry
5556 // that was never run leaves its durable writer undrained.
56-func NewAuthority(epoch ports.BrokerEpoch, registry *Registry, pool *Pool, supervisor *Supervisor, clocks ...ports.Clock) (*Authority, error) {
57+func NewAuthority(epoch ports.BrokerEpoch, registry *Registry, pool *Pool, supervisor *Supervisor, codec ports.SessionCodec, clocks ...ports.Clock) (*Authority, error) {
5758 if epoch == 0 || nilDependency(registry) || nilDependency(pool) || nilDependency(supervisor) {
5859 return nil, errors.New("broker: invalid authority dependencies")
5960 }
@@ -64,10 +65,10 @@ func NewAuthority(epoch ports.BrokerEpoch, registry *Registry, pool *Pool, super
6465 if len(clocks) > 0 {
6566 clk = clocks[0]
6667 }
67- if nilDependency(clk) {
68+ if nilDependency(clk) || nilDependency(codec) {
6869 return nil, errors.New("broker: invalid authority clock")
6970 }
70- return &Authority{epoch: epoch, registry: registry, pool: pool, supervisor: supervisor, clock: clk}, nil
71+ return &Authority{epoch: epoch, registry: registry, pool: pool, supervisor: supervisor, clock: clk, codec: codec}, nil
7172 }
7273
7374 // AdmitClient admits exactly one accepted client connection. The supervisor
@@ -76,7 +77,7 @@ func NewAuthority(epoch ports.BrokerEpoch, registry *Registry, pool *Pool, super
7677 // commits both or neither. ctx bounds admission only and is never retained: the
7778 // returned service derives its own connection-lived context from the supervisor
7879 // root, so a caller's setup deadline cannot disturb an admitted connection.
79-func (a *Authority) AdmitClient(ctx context.Context) (ports.BrokerService, error) {
80+func (a *Authority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) {
8081 if err := ctx.Err(); err != nil {
8182 return nil, err
8283 }
@@ -103,12 +104,12 @@ func (a *Authority) AdmitClient(ctx context.Context) (ports.BrokerService, error
103104 }
104105 return newService(serviceConfig{
105106 epoch: a.epoch, id: id, previewID: previewID, registry: a.registry,
106- pool: a.pool, supervisor: a.supervisor, lease: lease, clock: a.clock,
107+ pool: a.pool, supervisor: a.supervisor, lease: lease, clock: a.clock, codec: a.codec,
107108 }), nil
108109 }
109110
110111 // Service is one admitted client connection: the core's service for exactly one
111-// pool connection identity and broker epoch. It implements ports.BrokerService.
112+// pool connection identity and broker epoch. It implements ports.BrokerCoreService.
112113 type Service struct {
113114 epoch ports.BrokerEpoch
114115 id ports.BrokerConnectionID
@@ -118,6 +119,7 @@ type Service struct {
118119 supervisor *Supervisor
119120 lease *Lease
120121 clock ports.Clock
122+ codec ports.SessionCodec
121123
122124 // ctx owns everything this connection started: in-flight setup opens and
123125 // live streams. It is derived from the supervisor root, never from the
@@ -154,7 +156,7 @@ type Service struct {
154156 termErr error
155157 }
156158
157-var _ ports.BrokerService = (*Service)(nil)
159+var _ ports.BrokerCoreService = (*Service)(nil)
158160
159161 type serviceConfig struct {
160162 epoch ports.BrokerEpoch
@@ -164,11 +166,12 @@ type serviceConfig struct {
164166 supervisor *Supervisor
165167 lease *Lease
166168 clock ports.Clock
169+ codec ports.SessionCodec
167170 }
168171
169172 func (c serviceConfig) validate() error {
170173 if c.epoch == 0 || c.id == (ports.BrokerConnectionID{}) || c.previewID == (ports.BrokerConnectionID{}) || c.id == c.previewID ||
171- nilDependency(c.registry) || nilDependency(c.pool) || nilDependency(c.supervisor) || nilDependency(c.lease) || nilDependency(c.clock) {
174+ nilDependency(c.registry) || nilDependency(c.pool) || nilDependency(c.supervisor) || nilDependency(c.lease) || nilDependency(c.clock) || nilDependency(c.codec) {
172175 return errors.New("broker: invalid service dependencies")
173176 }
174177 return nil
@@ -180,7 +183,7 @@ func newService(c serviceConfig) *Service {
180183 }
181184 ctx, cancel := context.WithCancel(c.supervisor.RootContext())
182185 s := &Service{
183- epoch: c.epoch, id: c.id, previewID: c.previewID, registry: c.registry, pool: c.pool, supervisor: c.supervisor, lease: c.lease, clock: c.clock,
186+ epoch: c.epoch, id: c.id, previewID: c.previewID, registry: c.registry, pool: c.pool, supervisor: c.supervisor, lease: c.lease, clock: c.clock, codec: c.codec,
184187 ctx: ctx, cancel: cancel, subs: make(map[*serviceSubscription]struct{}),
185188 done: make(chan struct{}),
186189 }
@@ -284,7 +287,7 @@ func (s *Service) subscribe(demand bool) (ports.BrokerSubscription, error) {
284287 // the pool sees it, and one operation lease pins the broker only while setup is
285288 // in flight: a stream that opens successfully outlives its setup lease, and
286289 // Close or broker shutdown still aborts anything that has not finished.
287-func (s *Service) OpenStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
290+func (s *Service) OpenEnvelopeStream(ctx context.Context, request ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
288291 if err := s.scope(&request); err != nil {
289292 return nil, err
290293 }
M internal/usecase/broker/service_preview.go +4 -3
@@ -199,7 +199,7 @@ func (p *servicePreviewSubscription) watch() (reopen, delivered bool) {
199199 interval = previewLocalInterval
200200 }
201201 route, err := p.service.previewStreamRequest(p.request.Route)
202- var stream ports.BrokerLogicalConnection
202+ var stream ports.BrokerEnvelopeStream
203203 if err == nil {
204204 stream, err = p.service.pool.OpenStream(p.ctx, route)
205205 }
@@ -209,7 +209,8 @@ func (p *servicePreviewSubscription) watch() (reopen, delivered bool) {
209209 defer func() { _ = stream.Close() }()
210210 stop := context.AfterFunc(p.ctx, func() { _ = stream.Close() })
211211 defer stop()
212- if err := stream.SendClient(protocol.RemotePreviewWatch{Request: p.request.Preview, MinInterval: interval}); err != nil {
212+ typed := p.service.codec.Client(stream)
213+ if err := typed.SendClient(protocol.RemotePreviewWatch{Request: p.request.Preview, MinInterval: interval}); err != nil {
213214 return p.fail(err), false
214215 }
215216
@@ -232,7 +233,7 @@ func (p *servicePreviewSubscription) watch() (reopen, delivered bool) {
232233 defer func() { markFirst(); <-deadlineDone }()
233234
234235 for {
235- message, err := stream.ReceiveServer()
236+ message, err := typed.ReceiveServer()
236237 if err != nil {
237238 return p.fail(err), delivered
238239 }
M internal/usecase/broker/service_preview_test.go +7 -4
@@ -58,6 +58,8 @@ func (c *previewWatchConn) Capabilities() protocol.ConnectionCapabilities {
5858 }
5959 func (c *previewWatchConn) LinkState() ports.LinkState { return ports.LinkStateConnected }
6060 func (c *previewWatchConn) LinkEvents() <-chan ports.LinkEvent { return nil }
61+func (c *previewWatchConn) SendEnvelope([]byte) error { return nil }
62+func (c *previewWatchConn) RecvEnvelope() ([]byte, error) { <-c.done; return nil, errors.New("closed") }
6163 func (c *previewWatchConn) Done() <-chan struct{} { return c.done }
6264 func (c *previewWatchConn) Err() error { return nil }
6365 func (c *previewWatchConn) Close() error {
@@ -80,7 +82,7 @@ type previewTestConnector struct {
8082
8183 func (c *previewTestConnector) Connect(_ context.Context, e ports.BrokerDialTarget) (ports.BrokerPhysicalConnection, error) {
8284 if c.scripted == nil {
83- c.scripted = &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(_ context.Context, r ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
85+ c.scripted = &fakePhysical{endpoint: e, done: make(chan struct{}), open: func(_ context.Context, r ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
8486 conn := newPreviewWatchConn(r.Stream)
8587 c.opened <- conn
8688 return conn, nil
@@ -96,7 +98,7 @@ func previewTarget(lifecycle byte, tab string) domain.RemoteSessionTarget {
9698 }
9799 }
98100
99-func previewRequestFor(service ports.BrokerService, generation ports.BrokerPreviewGeneration, target domain.RemoteSessionTarget) ports.BrokerPreviewRequest {
101+func previewRequestFor(service ports.BrokerCoreService, generation ports.BrokerPreviewGeneration, target domain.RemoteSessionTarget) ports.BrokerPreviewRequest {
100102 return ports.BrokerPreviewRequest{
101103 Epoch: 1, Connection: service.ConnectionID(), Generation: generation,
102104 Route: ports.BrokerPreviewRoute{Local: true, Policy: poolPolicy()},
@@ -110,7 +112,7 @@ func previewAnswer(lifecycle byte, tab string, width, height int) protocol.Remot
110112
111113 type previewFixture struct {
112114 t *testing.T
113- service ports.BrokerService
115+ service ports.BrokerCoreService
114116 sub ports.BrokerPreviewSubscription
115117 connector *previewTestConnector
116118 clock *manualClock
@@ -125,6 +127,7 @@ func newPreviewFixture(t *testing.T, target domain.RemoteSessionTarget) *preview
125127 registry, err := NewRegistryWithConfig(1, newTestStore(), nil, clock, nil, RegistryConfig{ObservationDisabled: true})
126128 require.NoError(t, err)
127129 authority, _, _, _ := composeTestAuthority(t, 1, registry, connector.Connect, clock)
130+ authority.codec = testSessionCodec{}
128131 service, err := authority.AdmitClient(context.Background())
129132 require.NoError(t, err)
130133 t.Cleanup(func() { require.NoError(t, service.Close()) })
@@ -197,7 +200,7 @@ func TestServicePreviewStreamIDsDoNotConsumeClientIDs(t *testing.T) {
197200 id, err := service.NextStreamID()
198201 require.NoError(t, err)
199202 require.Equal(t, want, id)
200- stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), uint64(id)))
203+ stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), uint64(id)))
201204 require.NoError(t, err)
202205 t.Cleanup(func() { require.NoError(t, stream.Close()) })
203206 }
M internal/usecase/broker/service_test.go +33 -22
@@ -43,7 +43,7 @@ func composeTestAuthority(t testing.TB, epoch ports.BrokerEpoch, registry *Regis
4343 require.NoError(t, err)
4444 t.Cleanup(func() { require.NoError(t, pool.Close()) })
4545 supervisor, idleClock := newTestSupervisor(t, time.Hour)
46- authority, err := NewAuthority(epoch, registry, pool, supervisor)
46+ authority, err := NewAuthority(epoch, registry, pool, supervisor, testSessionCodec{})
4747 require.NoError(t, err)
4848 // The caller owns Registry.Run (see NewAuthority): start the single run and
4949 // cancel it at cleanup, so the registry's durable writer is drained and its
@@ -195,7 +195,7 @@ func TestAuthorityAdmissionContextNotRetained(t *testing.T) {
195195 require.NoError(t, registry.setHosts(hostRecords(registration(t, "user@host:22", 1))))
196196 require.Len(t, service.Snapshot().Daemons, 1)
197197
198- stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1))
198+ stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1))
199199 require.NoError(t, err)
200200 require.NoError(t, stream.Close())
201201 }
@@ -210,7 +210,7 @@ func TestAuthorityValidation(t *testing.T) {
210210 require.NoError(t, err)
211211 t.Cleanup(mutableRemote.settle)
212212 require.NoError(t, mutableRemote.setHosts(hostRecords(registration(t, "user@host:22", 1))))
213- _, err = NewAuthority(1, mutableRemote, pool, supervisor)
213+ _, err = NewAuthority(1, mutableRemote, pool, supervisor, testSessionCodec{})
214214 require.NoError(t, err, "a mutable remote registry must be served")
215215
216216 // A local-only observer is served: its entry is configured authority rather
@@ -223,7 +223,7 @@ func TestAuthorityValidation(t *testing.T) {
223223 }})
224224 require.NoError(t, err)
225225 t.Cleanup(localOnly.settle)
226- _, err = NewAuthority(1, localOnly, pool, supervisor)
226+ _, err = NewAuthority(1, localOnly, pool, supervisor, testSessionCodec{})
227227 require.NoError(t, err, "a local-only observer must be served")
228228
229229 // Construction still rejects remote observation without a probe: a registry
@@ -235,17 +235,17 @@ func TestAuthorityValidation(t *testing.T) {
235235 disabled, err := NewRegistryWithConfig(1, newTestStore(), nil, clock, nil, RegistryConfig{ObservationDisabled: true})
236236 require.NoError(t, err)
237237 t.Cleanup(disabled.settle)
238- _, err = NewAuthority(2, disabled, pool, supervisor)
238+ _, err = NewAuthority(2, disabled, pool, supervisor, testSessionCodec{})
239239 require.Error(t, err, "an epoch mismatch must be refused")
240240
241- _, err = NewAuthority(1, nil, pool, supervisor)
241+ _, err = NewAuthority(1, nil, pool, supervisor, testSessionCodec{})
242242 require.Error(t, err, "a missing registry must be refused")
243- _, err = NewAuthority(1, disabled, nil, supervisor)
243+ _, err = NewAuthority(1, disabled, nil, supervisor, testSessionCodec{})
244244 require.Error(t, err, "a missing pool must be refused")
245- _, err = NewAuthority(1, disabled, pool, nil)
245+ _, err = NewAuthority(1, disabled, pool, nil, testSessionCodec{})
246246 require.Error(t, err, "a missing supervisor must be refused")
247247
248- _, err = NewAuthority(1, disabled, pool, supervisor)
248+ _, err = NewAuthority(1, disabled, pool, supervisor, testSessionCodec{})
249249 require.NoError(t, err)
250250 }
251251
@@ -289,7 +289,7 @@ func TestServiceOpenStreamScopeFencing(t *testing.T) {
289289 require.NoError(t, err)
290290 t.Cleanup(func() { require.NoError(t, service.Close()) })
291291
292- stream, err := service.OpenStream(context.Background(), tc.build(service.ConnectionID()))
292+ stream, err := service.OpenEnvelopeStream(context.Background(), tc.build(service.ConnectionID()))
293293 switch {
294294 case tc.wantStale:
295295 require.ErrorIs(t, err, ports.BrokerAdmissionStale)
@@ -344,7 +344,7 @@ func TestServiceOpenStreamRequestsLocalReprobeOnOpenAndClose(t *testing.T) {
344344 waitLocal(t, registry, func(o ports.BrokerDaemonObservation) bool { return !o.Checking })
345345
346346 // Opening a local control stream must itself mark a re-probe pending.
347- stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1))
347+ stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1))
348348 require.NoError(t, err)
349349 opened := receiveLocalCall(t, local)
350350 opened.result <- reachable()
@@ -421,11 +421,11 @@ func TestServiceNextStreamIDAllocation(t *testing.T) {
421421 require.NoError(t, err)
422422 request := poolRequest(service.ConnectionID(), 0)
423423 request.Stream = stream
424- opened, err := service.OpenStream(context.Background(), request)
424+ opened, err := service.OpenEnvelopeStream(context.Background(), request)
425425 require.NoError(t, err)
426426 require.NoError(t, opened.Close())
427427 // Replaying the exact identity is refused as stale.
428- _, err = service.OpenStream(context.Background(), request)
428+ _, err = service.OpenEnvelopeStream(context.Background(), request)
429429 require.ErrorIs(t, err, ports.BrokerAdmissionStale)
430430 })
431431 }
@@ -448,7 +448,7 @@ func TestServiceOpenStreamAdmissionValidatesCallerInput(t *testing.T) {
448448 t.Run(tc.name, func(t *testing.T) {
449449 request := poolRequest(service.ConnectionID(), 1)
450450 tc.mutate(&request)
451- _, err := service.OpenStream(context.Background(), request)
451+ _, err := service.OpenEnvelopeStream(context.Background(), request)
452452 require.ErrorIs(t, err, ports.BrokerAdmissionInvalid)
453453 })
454454 }
@@ -461,7 +461,7 @@ func TestServiceCloseStreamScopeFencing(t *testing.T) {
461461 t.Cleanup(func() { require.NoError(t, service.Close()) })
462462 id := service.ConnectionID()
463463
464- stream, err := service.OpenStream(context.Background(), poolRequest(id, 1))
464+ stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(id, 1))
465465 require.NoError(t, err)
466466
467467 // A wrong-scope close must not retire this connection's stream.
@@ -610,12 +610,12 @@ func TestServiceOperationLeaseLifetime(t *testing.T) {
610610 t.Cleanup(func() { require.NoError(t, service.Close()) })
611611
612612 type opened struct {
613- stream ports.BrokerLogicalConnection
613+ stream ports.BrokerEnvelopeStream
614614 err error
615615 }
616616 result := make(chan opened, 1)
617617 go func() {
618- stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1))
618+ stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1))
619619 result <- opened{stream: stream, err: err}
620620 }()
621621 <-entered
@@ -656,7 +656,7 @@ func TestServiceCloseOpenRace(t *testing.T) {
656656
657657 result := make(chan error, 1)
658658 go func() {
659- _, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1))
659+ _, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1))
660660 result <- err
661661 }()
662662 <-entered
@@ -683,7 +683,7 @@ func TestServiceCloseIsIdempotentAndConcurrent(t *testing.T) {
683683 require.NoError(t, err)
684684 _, err = service.Subscribe()
685685 require.NoError(t, err)
686- stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1))
686+ stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1))
687687 require.NoError(t, err)
688688
689689 const closers = 8
@@ -708,7 +708,7 @@ func TestServiceCloseIsIdempotentAndConcurrent(t *testing.T) {
708708 require.Zero(t, clients)
709709 await(t, stream.Done())
710710
711- _, err = service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 2))
711+ _, err = service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 2))
712712 requireBrokerClosed(t, err)
713713 }
714714
@@ -747,7 +747,7 @@ func TestServiceShutdownTerminatesOwnedWork(t *testing.T) {
747747 service, err := authority.AdmitClient(context.Background())
748748 require.NoError(t, err)
749749
750- stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1))
750+ stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1))
751751 require.NoError(t, err)
752752
753753 // Broker shutdown cancels the connection root: owned streams end even before
@@ -1156,7 +1156,7 @@ func TestRegistryObservationDisabledDrainsWriter(t *testing.T) {
11561156 }
11571157
11581158 func TestServiceConfigValidation(t *testing.T) {
1159- valid := serviceConfig{epoch: 1, id: ports.BrokerConnectionID{1}, previewID: ports.BrokerConnectionID{2}, registry: &Registry{}, pool: &Pool{}, supervisor: &Supervisor{}, lease: &Lease{}, clock: newManualClock(time.Unix(0, 0))}
1159+ valid := serviceConfig{epoch: 1, id: ports.BrokerConnectionID{1}, previewID: ports.BrokerConnectionID{2}, registry: &Registry{}, pool: &Pool{}, supervisor: &Supervisor{}, lease: &Lease{}, clock: newManualClock(time.Unix(0, 0)), codec: testSessionCodec{}}
11601160 tests := []struct {
11611161 name string
11621162 mutate func(*serviceConfig)
@@ -1170,6 +1170,7 @@ func TestServiceConfigValidation(t *testing.T) {
11701170 {"nil supervisor", func(c *serviceConfig) { c.supervisor = nil }},
11711171 {"nil lease", func(c *serviceConfig) { c.lease = nil }},
11721172 {"nil clock", func(c *serviceConfig) { c.clock = nil }},
1173+ {"nil codec", func(c *serviceConfig) { c.codec = nil }},
11731174 }
11741175 require.NoError(t, valid.validate())
11751176 for _, tt := range tests {
@@ -1180,3 +1181,13 @@ func TestServiceConfigValidation(t *testing.T) {
11801181 })
11811182 }
11821183 }
1184+
1185+// testSessionCodec is used only for scripted preview streams; raw traffic is never decoded.
1186+type testSessionCodec struct{}
1187+
1188+func (testSessionCodec) Client(stream ports.BrokerEnvelopeStream) ports.ClientConnection {
1189+ if pooled, ok := stream.(*pooledStream); ok {
1190+ stream = pooled.BrokerEnvelopeStream
1191+ }
1192+ return stream.(*previewWatchConn)
1193+}
M internal/usecase/client/supervisor_integration_test.go +2 -2
@@ -65,7 +65,7 @@ func (c *integrationCore) SubscribePreview(ports.BrokerPreviewRequest) (ports.Br
6565 return nil, errors.New("integration core does not support preview")
6666 }
6767
68-func (c *integrationCore) OpenStream(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) {
68+func (c *integrationCore) OpenEnvelopeStream(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) {
6969 return nil, errors.New("integration core does not support streams")
7070 }
7171
@@ -110,7 +110,7 @@ type integrationAuthority struct {
110110
111111 var _ ports.BrokerAuthority = (*integrationAuthority)(nil)
112112
113-func (a *integrationAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) {
113+func (a *integrationAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) {
114114 if err := ctx.Err(); err != nil {
115115 return nil, err
116116 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close