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 Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
36 files · +2540 -505
M internal/adapters/brokeripc/helpers_test.go +39 -17
| @@ -1,6 +1,7 @@ | |||
| 1 | 1 | package brokeripc | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | + | "bytes" | |
| 4 | 5 | "context" | |
| 5 | 6 | "encoding/binary" | |
| 6 | 7 | "errors" | |
| @@ -15,6 +16,7 @@ import ( | |||
| 15 | 16 | "github.com/stretchr/testify/require" | |
| 16 | 17 | ||
| 17 | 18 | "github.com/bnema/vev/internal/adapters/brokerwire" | |
| 19 | + | "github.com/bnema/vev/internal/adapters/sessionwire" | |
| 18 | 20 | "github.com/bnema/vev/internal/domain" | |
| 19 | 21 | "github.com/bnema/vev/internal/ports" | |
| 20 | 22 | "github.com/bnema/vev/internal/protocol" | |
| @@ -72,7 +74,7 @@ func attachmentRequest(stream ports.BrokerStreamID, admission ports.BrokerStream | |||
| 72 | 74 | ||
| 73 | 75 | // nextStreamID reads one fresh identity from the service's only allocator, | |
| 74 | 76 | // 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 { | |
| 76 | 78 | t.Helper() | |
| 77 | 79 | stream, err := service.NextStreamID() | |
| 78 | 80 | require.NoError(t, err) | |
| @@ -87,14 +89,14 @@ const membershipProbeEndpoint = "probe@host:22" | |||
| 87 | 89 | // membership round trip after a stream-local or subscriber-local event: the | |
| 88 | 90 | // probe adds one host through the same delegated path a real caller uses and | |
| 89 | 91 | // 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) { | |
| 91 | 93 | t.Helper() | |
| 92 | 94 | require.NoError(t, connectionDelegates(context.Background(), service)) | |
| 93 | 95 | } | |
| 94 | 96 | ||
| 95 | 97 | // connectionDelegates is the error-returning form of requireConnectionDelegates, | |
| 96 | 98 | // 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 { | |
| 98 | 100 | ctx, cancel := context.WithTimeout(ctx, 5*time.Second) | |
| 99 | 101 | defer cancel() | |
| 100 | 102 | registration, err := service.AddHost(ctx, membershipProbeEndpoint, testPolicy()) | |
| @@ -284,22 +286,38 @@ func (s *fakeSubscription) notify() { | |||
| 284 | 286 | type fakeLogicalConn struct { | |
| 285 | 287 | fromClient chan protocol.ClientMessage | |
| 286 | 288 | 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 | |
| 292 | 297 | } | |
| 293 | 298 | ||
| 294 | 299 | func newFakeLogicalConn() *fakeLogicalConn { | |
| 295 | 300 | return &fakeLogicalConn{ | |
| 296 | 301 | fromClient: make(chan protocol.ClientMessage, 64), | |
| 297 | 302 | toClient: make(chan protocol.ServerMessage, 64), | |
| 303 | + | preamble: make(chan []byte, 1), | |
| 298 | 304 | done: make(chan struct{}), | |
| 299 | 305 | } | |
| 300 | 306 | } | |
| 301 | 307 | ||
| 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 | + | } | |
| 303 | 321 | select { | |
| 304 | 322 | case c.fromClient <- message: | |
| 305 | 323 | return nil | |
| @@ -308,20 +326,24 @@ func (c *fakeLogicalConn) SendClient(message protocol.ClientMessage) error { | |||
| 308 | 326 | } | |
| 309 | 327 | } | |
| 310 | 328 | ||
| 311 | - | func (c *fakeLogicalConn) ReceiveServer() (protocol.ServerMessage, error) { | |
| 329 | + | func (c *fakeLogicalConn) RecvEnvelope() ([]byte, error) { | |
| 312 | 330 | // A message already queued when Close ran must still be observed first: a | |
| 313 | 331 | // real carriage never reports the connection done before a message the peer | |
| 314 | 332 | // sent ahead of an orderly close has been delivered. Draining non-blocking | |
| 315 | 333 | // before the select keeps that ordering deterministic instead of racing a | |
| 316 | 334 | // buffered send against an already-closed done channel. | |
| 317 | 335 | select { | |
| 336 | + | case response := <-c.preamble: | |
| 337 | + | return response, nil | |
| 318 | 338 | case message := <-c.toClient: | |
| 319 | - | return message, nil | |
| 339 | + | return sessionwire.EncodeServerMessage(message) | |
| 320 | 340 | default: | |
| 321 | 341 | } | |
| 322 | 342 | select { | |
| 343 | + | case response := <-c.preamble: | |
| 344 | + | return response, nil | |
| 323 | 345 | case message := <-c.toClient: | |
| 324 | - | return message, nil | |
| 346 | + | return sessionwire.EncodeServerMessage(message) | |
| 325 | 347 | case <-c.done: | |
| 326 | 348 | if err := c.Err(); err != nil { | |
| 327 | 349 | return nil, err | |
| @@ -487,7 +509,7 @@ func (c *fakeCore) SubscribePreview(ports.BrokerPreviewRequest) (ports.BrokerPre | |||
| 487 | 509 | return newFakePreviewSubscription(), nil | |
| 488 | 510 | } | |
| 489 | 511 | ||
| 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) { | |
| 491 | 513 | c.mu.Lock() | |
| 492 | 514 | defer c.mu.Unlock() | |
| 493 | 515 | if c.openErr != nil { | |
| @@ -721,7 +743,7 @@ func newFakeAuthority(epoch ports.BrokerEpoch, snapshot ports.BrokerSnapshot) *f | |||
| 721 | 743 | return &fakeAuthority{hub: newSnapshotHub(snapshot), epoch: epoch} | |
| 722 | 744 | } | |
| 723 | 745 | ||
| 724 | - | func (a *fakeAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) { | |
| 746 | + | func (a *fakeAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) { | |
| 725 | 747 | if err := ctx.Err(); err != nil { | |
| 726 | 748 | return nil, err | |
| 727 | 749 | } | |
| @@ -770,10 +792,10 @@ func startEndpoint(t *testing.T, cfg Config) *endpoint { | |||
| 770 | 792 | } | |
| 771 | 793 | ||
| 772 | 794 | // accept returns the next admitted session. | |
| 773 | - | func (e *endpoint) accept() ports.BrokerService { | |
| 795 | + | func (e *endpoint) accept() ports.BrokerCoreService { | |
| 774 | 796 | e.t.Helper() | |
| 775 | 797 | type result struct { | |
| 776 | - | service ports.BrokerService | |
| 798 | + | service ports.BrokerCoreService | |
| 777 | 799 | err error | |
| 778 | 800 | } | |
| 779 | 801 | out := make(chan result, 1) | |
| @@ -807,7 +829,7 @@ func (e *endpoint) dialWith(cfg Config) ports.BrokerService { | |||
| 807 | 829 | } | |
| 808 | 830 | ||
| 809 | 831 | // 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) { | |
| 811 | 833 | e.t.Helper() | |
| 812 | 834 | client := e.dial() | |
| 813 | 835 | session := e.accept() | |
M internal/adapters/brokeripc/listen_test.go +3 -3
| @@ -27,7 +27,7 @@ type gatedAuthority struct { | |||
| 27 | 27 | once sync.Once | |
| 28 | 28 | } | |
| 29 | 29 | ||
| 30 | - | func (a *gatedAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) { | |
| 30 | + | func (a *gatedAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) { | |
| 31 | 31 | a.once.Do(func() { close(a.entered) }) | |
| 32 | 32 | <-a.gate | |
| 33 | 33 | return a.inner.AdmitClient(ctx) | |
| @@ -41,7 +41,7 @@ type ctxAuthority struct { | |||
| 41 | 41 | once sync.Once | |
| 42 | 42 | } | |
| 43 | 43 | ||
| 44 | - | func (a *ctxAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) { | |
| 44 | + | func (a *ctxAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) { | |
| 45 | 45 | a.once.Do(func() { close(a.entered) }) | |
| 46 | 46 | <-ctx.Done() | |
| 47 | 47 | return nil, ctx.Err() | |
| @@ -429,7 +429,7 @@ func TestStalledHandshakeDoesNotBlockOtherClients(t *testing.T) { | |||
| 429 | 429 | func TestConcurrentDialAndClose(t *testing.T) { | |
| 430 | 430 | e := startEndpoint(t, Config{MaxClients: 8, HandshakeTimeout: 2 * time.Second}) | |
| 431 | 431 | ||
| 432 | - | sessions := make(chan ports.BrokerService, 8) | |
| 432 | + | sessions := make(chan ports.BrokerCoreService, 8) | |
| 433 | 433 | go func() { | |
| 434 | 434 | defer close(sessions) | |
| 435 | 435 | 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 | |||
| 57 | 57 | // serverPreviewGeneration returns the server session's current preview | |
| 58 | 58 | // generation: it observes the same replacement bookkeeping startPreview | |
| 59 | 59 | // 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 { | |
| 61 | 61 | server, ok := session.(*serverSession) | |
| 62 | 62 | if !ok { | |
| 63 | 63 | return 0 | |
| @@ -68,7 +68,7 @@ func serverPreviewGeneration(session ports.BrokerService) ports.BrokerPreviewGen | |||
| 68 | 68 | } | |
| 69 | 69 | ||
| 70 | 70 | // 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 { | |
| 72 | 72 | server, ok := session.(*serverSession) | |
| 73 | 73 | if !ok { | |
| 74 | 74 | 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 { | |||
| 281 | 281 | // credential, or an unsupported build) or a client that fails the preamble or | |
| 282 | 282 | // admission is isolated: that peer is dropped and the listener keeps serving. | |
| 283 | 283 | // 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) { | |
| 285 | 285 | if l == nil { | |
| 286 | 286 | return nil, ErrListenerClosed | |
| 287 | 287 | } | |
| @@ -466,7 +466,7 @@ type serverSession struct { | |||
| 466 | 466 | epoch ports.BrokerEpoch | |
| 467 | 467 | scope brokerwire.Scope | |
| 468 | 468 | conn *brokerwire.Connection | |
| 469 | - | core ports.BrokerService | |
| 469 | + | core ports.BrokerCoreService | |
| 470 | 470 | transport wire.BoundedTransport | |
| 471 | 471 | ceilings brokerwire.Ceilings | |
| 472 | 472 | cfg Config | |
| @@ -513,7 +513,7 @@ type serverSession struct { | |||
| 513 | 513 | done chan struct{} | |
| 514 | 514 | } | |
| 515 | 515 | ||
| 516 | - | var _ ports.BrokerService = (*serverSession)(nil) | |
| 516 | + | var _ ports.BrokerCoreService = (*serverSession)(nil) | |
| 517 | 517 | ||
| 518 | 518 | // registrationDeadline returns the absolute instant by which an accepted client | |
| 519 | 519 | // must send its Register: the accept-time handshake deadline that already | |
| @@ -535,7 +535,7 @@ func registrationDeadline(ctx context.Context) time.Time { | |||
| 535 | 535 | // registerDeadline is the absolute instant by which the client's Register must | |
| 536 | 536 | // arrive (the accept-time handshake deadline); the zero time disables the bound | |
| 537 | 537 | // 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) { | |
| 539 | 539 | if epoch == 0 || transport == nil || core == nil { | |
| 540 | 540 | return nil, ErrConfig | |
| 541 | 541 | } | |
| @@ -983,14 +983,14 @@ func (s *serverSession) SubscribePreview(request ports.BrokerPreviewRequest) (po | |||
| 983 | 983 | // allocated (NextStreamID) and is transmitted unchanged: this listener never | |
| 984 | 984 | // re-allocates a wire identity, whether the request arrives over the wire or | |
| 985 | 985 | // 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) { | |
| 987 | 987 | if err := s.checkRequestScope(request.Epoch, request.Connection); err != nil { | |
| 988 | 988 | return nil, err | |
| 989 | 989 | } | |
| 990 | 990 | scoped := request | |
| 991 | 991 | scoped.Epoch = s.epoch | |
| 992 | 992 | scoped.Connection = s.scope.Connection | |
| 993 | - | return s.core.OpenStream(ctx, scoped) | |
| 993 | + | return s.core.OpenEnvelopeStream(ctx, scoped) | |
| 994 | 994 | } | |
| 995 | 995 | ||
| 996 | 996 | // 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) { | |||
| 110 | 110 | ||
| 111 | 111 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) | |
| 112 | 112 | defer cancel() | |
| 113 | - | opened, err := session.OpenStream(ctx, openRequest(1)) | |
| 113 | + | opened, err := session.OpenEnvelopeStream(ctx, openRequest(1)) | |
| 114 | 114 | require.NoError(t, err) | |
| 115 | 115 | require.NotNil(t, opened) | |
| 116 | 116 | ||
M internal/adapters/brokeripc/stream.go +23 -29
| @@ -9,16 +9,14 @@ import ( | |||
| 9 | 9 | "github.com/bnema/vev/internal/adapters/brokerwire" | |
| 10 | 10 | "github.com/bnema/vev/internal/adapters/sessionwire" | |
| 11 | 11 | "github.com/bnema/vev/internal/ports" | |
| 12 | + | "github.com/bnema/vev/internal/protocol/wire" | |
| 12 | 13 | ) | |
| 13 | 14 | ||
| 14 | 15 | // Logical stream bridging. | |
| 15 | 16 | // | |
| 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. | |
| 22 | 20 | // | |
| 23 | 21 | // Identity and cancellation stay per stream: a stream the core loses, a stream | |
| 24 | 22 | // whose local consumer stalled, and a stream the peer closed each settle alone, | |
| @@ -29,10 +27,9 @@ import ( | |||
| 29 | 27 | type serverStream struct { | |
| 30 | 28 | session *serverSession | |
| 31 | 29 | id ports.BrokerStreamID | |
| 32 | - | core ports.BrokerLogicalConnection | |
| 30 | + | core ports.BrokerEnvelopeStream | |
| 33 | 31 | pipe *streamPipe | |
| 34 | 32 | carriage *carriage | |
| 35 | - | wire ports.ServerConnection | |
| 36 | 33 | ||
| 37 | 34 | mu sync.Mutex | |
| 38 | 35 | closed bool | |
| @@ -40,17 +37,13 @@ type serverStream struct { | |||
| 40 | 37 | } | |
| 41 | 38 | ||
| 42 | 39 | // 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) { | |
| 44 | 41 | if s == nil || core == nil || id == 0 { | |
| 45 | 42 | return nil, ErrConfig | |
| 46 | 43 | } | |
| 47 | 44 | st := &serverStream{session: s, id: id, core: core, done: make(chan struct{})} | |
| 48 | 45 | st.pipe = newStreamPipe(s.cfg.StreamInboundChunks, s.cfg.StreamInboundBytes, st.sendChunk) | |
| 49 | 46 | st.carriage = newCarriage(st.pipe) | |
| 50 | - | st.wire = sessionwire.NewServerConnection(st.carriage) | |
| 51 | - | if st.wire == nil { | |
| 52 | - | return nil, ErrConfig | |
| 53 | - | } | |
| 54 | 47 | return st, nil | |
| 55 | 48 | } | |
| 56 | 49 | ||
| @@ -85,34 +78,36 @@ func (st *serverStream) start() { | |||
| 85 | 78 | go st.watchCore() | |
| 86 | 79 | } | |
| 87 | 80 | ||
| 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. | |
| 90 | 82 | func (st *serverStream) relayClient() { | |
| 91 | 83 | defer st.session.wg.Done() | |
| 92 | 84 | for { | |
| 93 | - | message, err := st.wire.ReceiveClient() | |
| 85 | + | envelope, err := st.carriage.RecvBounded(wire.AbsoluteEnvelopeLimit) | |
| 94 | 86 | if err != nil { | |
| 95 | 87 | st.fail(cancelOrCause(st.session.ctx, streamFailure(err))) | |
| 96 | 88 | return | |
| 97 | 89 | } | |
| 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)) | |
| 100 | 92 | return | |
| 101 | 93 | } | |
| 102 | 94 | } | |
| 103 | 95 | } | |
| 104 | 96 | ||
| 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. | |
| 107 | 98 | func (st *serverStream) relayServer() { | |
| 108 | 99 | defer st.session.wg.Done() | |
| 109 | 100 | for { | |
| 110 | - | message, err := st.core.ReceiveServer() | |
| 101 | + | payload, err := st.core.RecvEnvelope() | |
| 111 | 102 | if err != nil { | |
| 112 | 103 | st.fail(coreFailure(st.core, err)) | |
| 113 | 104 | return | |
| 114 | 105 | } | |
| 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 { | |
| 116 | 111 | st.fail(streamFailure(err)) | |
| 117 | 112 | return | |
| 118 | 113 | } | |
| @@ -121,10 +116,10 @@ func (st *serverStream) relayServer() { | |||
| 121 | 116 | ||
| 122 | 117 | // watchCore publishes the core connection's terminal outcome even when no read | |
| 123 | 118 | // 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() | |
| 125 | 120 | // call observes the same terminal outcome right after forwarding any reply | |
| 126 | 121 | // 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 | |
| 128 | 123 | // close the carriage while a received reply is still being written out to the | |
| 129 | 124 | // client, discarding it. | |
| 130 | 125 | func (st *serverStream) watchCore() { | |
| @@ -147,8 +142,7 @@ func (st *serverStream) fail(err error) { | |||
| 147 | 142 | } | |
| 148 | 143 | ||
| 149 | 144 | // 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. | |
| 152 | 146 | func (st *serverStream) close(cause error) bool { | |
| 153 | 147 | if st == nil { | |
| 154 | 148 | return false | |
| @@ -161,7 +155,7 @@ func (st *serverStream) close(cause error) bool { | |||
| 161 | 155 | st.closed = true | |
| 162 | 156 | st.mu.Unlock() | |
| 163 | 157 | st.pipe.closeWith(cause) | |
| 164 | - | _ = st.wire.Close() | |
| 158 | + | _ = st.carriage.Close() | |
| 165 | 159 | _ = st.core.Close() | |
| 166 | 160 | close(st.done) | |
| 167 | 161 | return true | |
| @@ -178,7 +172,7 @@ func streamFailure(err error) error { | |||
| 178 | 172 | ||
| 179 | 173 | // coreFailure classifies one core connection outcome. The core's typed terminal | |
| 180 | 174 | // 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 { | |
| 182 | 176 | if err == nil && core != nil { | |
| 183 | 177 | err = core.Err() | |
| 184 | 178 | } | |
| @@ -221,7 +215,7 @@ func (s *serverSession) startStream(m brokerwire.OpenStream) { | |||
| 221 | 215 | s.wg.Add(1) | |
| 222 | 216 | go func() { | |
| 223 | 217 | defer s.wg.Done() | |
| 224 | - | core, err := s.core.OpenStream(s.ctx, request) | |
| 218 | + | core, err := s.core.OpenEnvelopeStream(s.ctx, request) | |
| 225 | 219 | if err != nil { | |
| 226 | 220 | _, _ = s.conn.CloseStream(m.Stream) | |
| 227 | 221 | 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 { | |||
| 305 | 305 | // the LogicalConnector. A policy that differs in any field is refused as a | |
| 306 | 306 | // conflicting policy without touching the carriage, so a physical connection | |
| 307 | 307 | // 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) { | |
| 309 | 309 | if c == nil || c.logical == nil { | |
| 310 | 310 | return nil, ports.BrokerError{Code: ports.BrokerErrorIncompatible, Cause: ErrLogicalConfig} | |
| 311 | 311 | } | |
M internal/adapters/daemonmux/connector_test.go +4 -4
| @@ -292,7 +292,7 @@ func TestEndpointConnectorExposesAuthorityAndPolicyGuard(t *testing.T) { | |||
| 292 | 292 | require.Equal(t, domain.RemoteFailureNone, physical.FailureKind()) | |
| 293 | 293 | ||
| 294 | 294 | // 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()))) | |
| 296 | 296 | require.Error(t, err) | |
| 297 | 297 | var typed ports.BrokerError | |
| 298 | 298 | require.ErrorAs(t, err, &typed) | |
| @@ -300,7 +300,7 @@ func TestEndpointConnectorExposesAuthorityAndPolicyGuard(t *testing.T) { | |||
| 300 | 300 | require.Zero(t, server.acceptedCount(), "a policy-mismatched open is never admitted") | |
| 301 | 301 | ||
| 302 | 302 | // 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())) | |
| 304 | 304 | require.NoError(t, err) | |
| 305 | 305 | server.awaitAccepted(t, 1) | |
| 306 | 306 | require.NoError(t, logical.SendClient(protocol.Ping{})) | |
| @@ -334,7 +334,7 @@ func TestEndpointConnectorDetachesSetupContext(t *testing.T) { | |||
| 334 | 334 | cancel() | |
| 335 | 335 | // The setup context ended; the pooled connection must still work. | |
| 336 | 336 | 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())) | |
| 338 | 338 | require.NoError(t, err) | |
| 339 | 339 | server.awaitAccepted(t, 1) | |
| 340 | 340 | require.NoError(t, logical.SendClient(protocol.Ping{})) | |
| @@ -360,7 +360,7 @@ func TestPhysicalDoneBeforeLogicalLoss(t *testing.T) { | |||
| 360 | 360 | t.Cleanup(func() { _ = physical.Close() }) | |
| 361 | 361 | require.NoError(t, server.awaitAdoption(t)) | |
| 362 | 362 | ||
| 363 | - | logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 363 | + | logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 364 | 364 | require.NoError(t, err) | |
| 365 | 365 | server.awaitAccepted(t, 1) | |
| 366 | 366 | 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 { | |||
| 285 | 285 | } | |
| 286 | 286 | ||
| 287 | 287 | // 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) { | |
| 289 | 289 | t.Helper() | |
| 290 | + | conn := asTyped(stream) | |
| 290 | 291 | require.NoError(t, conn.SendClient(protocol.Ping{})) | |
| 291 | 292 | message, err := conn.ReceiveServer() | |
| 292 | 293 | 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. | |
| 2 | 2 | // | |
| 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. | |
| 10 | 6 | // | |
| 11 | 7 | // The carriage between the two is a private, ordered, bounded byte stream | |
| 12 | 8 | // (muxStreamPipe). Its read side pulls already-queued chunks from the pump | |
| @@ -24,10 +20,6 @@ | |||
| 24 | 20 | // resets exactly that stream (one mux Reset) and leaves every sibling and the | |
| 25 | 21 | // physical connection untouched. Done, Err, and a physical-loss | |
| 26 | 22 | // 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. | |
| 31 | 23 | package daemonmux | |
| 32 | 24 | ||
| 33 | 25 | import ( | |
| @@ -35,13 +27,10 @@ import ( | |||
| 35 | 27 | "errors" | |
| 36 | 28 | "io" | |
| 37 | 29 | "sync" | |
| 38 | - | "time" | |
| 39 | 30 | ||
| 40 | - | "github.com/bnema/vev/internal/adapters/sessionwire" | |
| 41 | 31 | "github.com/bnema/vev/internal/adapters/streamframe" | |
| 42 | 32 | "github.com/bnema/vev/internal/domain" | |
| 43 | 33 | "github.com/bnema/vev/internal/ports" | |
| 44 | - | "github.com/bnema/vev/internal/protocol" | |
| 45 | 34 | "github.com/bnema/vev/internal/protocol/wire" | |
| 46 | 35 | ) | |
| 47 | 36 | ||
| @@ -241,13 +230,9 @@ func discardQueuedInbound(pump *Pump, physical PhysicalStreamID) { | |||
| 241 | 230 | } | |
| 242 | 231 | } | |
| 243 | 232 | ||
| 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. | |
| 248 | 235 | type LogicalConnection struct { | |
| 249 | - | ports.ClientConnection | |
| 250 | - | ||
| 251 | 236 | pump *Pump | |
| 252 | 237 | ref StreamRef | |
| 253 | 238 | pipe *muxStreamPipe | |
| @@ -258,22 +243,16 @@ type LogicalConnection struct { | |||
| 258 | 243 | // keeps its exact cause even after the record is evicted. | |
| 259 | 244 | cause *terminalState | |
| 260 | 245 | ||
| 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 | |
| 268 | 247 | watchDone chan struct{} | |
| 269 | 248 | closeOnce sync.Once | |
| 270 | 249 | closeErr error | |
| 271 | 250 | } | |
| 272 | 251 | ||
| 273 | - | var _ ports.BrokerLogicalConnection = (*LogicalConnection)(nil) | |
| 252 | + | var _ ports.BrokerEnvelopeStream = (*LogicalConnection)(nil) | |
| 274 | 253 | ||
| 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 | |
| 277 | 256 | // stream's retained terminal authority, captured at open so the connection | |
| 278 | 257 | // reports its exact outcome independent of the engine's bounded record. | |
| 279 | 258 | 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{}, | |||
| 281 | 260 | pipe := newMuxStreamPipe(pump, ref.Physical, limit, streamDone) | |
| 282 | 261 | raw := newMuxTransport(pipe) | |
| 283 | 262 | 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{}), | |
| 299 | 271 | } | |
| 300 | 272 | go connection.watch() | |
| 301 | 273 | return connection | |
| @@ -304,25 +276,6 @@ func newLogicalConnection(pump *Pump, ref StreamRef, streamDone <-chan struct{}, | |||
| 304 | 276 | // Ref returns the complete stream reference recorded at admission. | |
| 305 | 277 | func (c *LogicalConnection) Ref() StreamRef { return c.ref } | |
| 306 | 278 | ||
| 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 | - | ||
| 326 | 279 | // Done returns the logical terminal channel independent of reads. It closes | |
| 327 | 280 | // exactly once, before Err becomes stable. | |
| 328 | 281 | func (c *LogicalConnection) Done() <-chan struct{} { return c.terminal.Done() } | |
| @@ -335,39 +288,26 @@ func (c *LogicalConnection) Err() error { return c.terminal.Err() } | |||
| 335 | 288 | // FailureKind classifies Err. It is None while open and for an orderly Close. | |
| 336 | 289 | func (c *LogicalConnection) FailureKind() domain.RemoteFailureKind { return c.terminal.FailureKind() } | |
| 337 | 290 | ||
| 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 { | |
| 342 | 292 | if c.settled() { | |
| 343 | 293 | return c.terminalError() | |
| 344 | 294 | } | |
| 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 | |
| 350 | 297 | } | |
| 351 | - | return nil | |
| 298 | + | return c.raw.Send(wire.Envelope{Payload: payload}) | |
| 352 | 299 | } | |
| 353 | 300 | ||
| 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) | |
| 369 | 309 | } | |
| 370 | - | return nil, c.abortMalformed(err) | |
| 310 | + | return envelope.Payload, nil | |
| 371 | 311 | } | |
| 372 | 312 | ||
| 373 | 313 | // Close independently closes the logical stream: it discards the inbound | |
| @@ -660,8 +600,7 @@ func (s *muxStreamPipe) Close() error { | |||
| 660 | 600 | } | |
| 661 | 601 | ||
| 662 | 602 | // 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. | |
| 665 | 604 | type muxTransport struct { | |
| 666 | 605 | pipe *muxStreamPipe | |
| 667 | 606 | framer *streamframe.Framer | |
M internal/adapters/daemonmux/logical_conn_test.go +8 -56
| @@ -318,13 +318,13 @@ func (a *daemonAcceptor) closePeers() { | |||
| 318 | 318 | } | |
| 319 | 319 | } | |
| 320 | 320 | ||
| 321 | - | func openWithDeadline(t *testing.T, connector *LogicalConnector, stream int) *LogicalConnection { | |
| 321 | + | func openWithDeadline(t *testing.T, connector *LogicalConnector, stream int) typedLogical { | |
| 322 | 322 | t.Helper() | |
| 323 | 323 | ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) | |
| 324 | 324 | defer cancel() | |
| 325 | 325 | connection, err := connector.Open(ctx, controlRequest(stream)) | |
| 326 | 326 | require.NoError(t, err) | |
| 327 | - | return connection | |
| 327 | + | return typedLogical{typedStream: asTyped(connection), LogicalConnection: connection} | |
| 328 | 328 | } | |
| 329 | 329 | ||
| 330 | 330 | // watchRegistered reports whether the pump still holds an inbound watch entry | |
| @@ -406,7 +406,7 @@ func TestLogicalTwoConnections(t *testing.T) { | |||
| 406 | 406 | acceptor.start(PhysicalStreamID(i), deadline) | |
| 407 | 407 | } | |
| 408 | 408 | ||
| 409 | - | connections := make([]*LogicalConnection, 0, count) | |
| 409 | + | connections := make([]typedLogical, 0, count) | |
| 410 | 410 | for i := 1; i <= count; i++ { | |
| 411 | 411 | connection := openWithDeadline(t, connector, i) | |
| 412 | 412 | require.NoError(t, connection.SendClient(protocol.Ping{}), "connection %d", i) | |
| @@ -487,11 +487,12 @@ func TestLogicalHundredConnectionsConcurrentAdmission(t *testing.T) { | |||
| 487 | 487 | traffic.Add(1) | |
| 488 | 488 | go func(index int) { | |
| 489 | 489 | 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 { | |
| 491 | 492 | trafficErrs[index] = err | |
| 492 | 493 | return | |
| 493 | 494 | } | |
| 494 | - | message, err := connections[index].ReceiveServer() | |
| 495 | + | message, err := typed.ReceiveServer() | |
| 495 | 496 | if err != nil { | |
| 496 | 497 | trafficErrs[index] = err | |
| 497 | 498 | return | |
| @@ -802,7 +803,7 @@ func TestLogicalPhysicalLossFanout(t *testing.T) { | |||
| 802 | 803 | for i := 1; i <= count; i++ { | |
| 803 | 804 | acceptor.start(PhysicalStreamID(i), deadline) | |
| 804 | 805 | } | |
| 805 | - | connections := make([]*LogicalConnection, 0, count) | |
| 806 | + | connections := make([]typedLogical, 0, count) | |
| 806 | 807 | for i := 1; i <= count; i++ { | |
| 807 | 808 | connection := openWithDeadline(t, connector, i) | |
| 808 | 809 | require.NoError(t, connection.SendClient(protocol.Ping{})) | |
| @@ -832,55 +833,6 @@ func TestLogicalPhysicalLossFanout(t *testing.T) { | |||
| 832 | 833 | require.Equal(t, domain.RemoteFailureTransport, brokerPump.FailureKind()) | |
| 833 | 834 | } | |
| 834 | 835 | ||
| 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 | |
| 884 | 836 | // connections leaves no goroutine behind. | |
| 885 | 837 | func TestLogicalNoGoroutineLeak(t *testing.T) { | |
| 886 | 838 | before := runtime.NumGoroutine() | |
| @@ -894,7 +846,7 @@ func TestLogicalNoGoroutineLeak(t *testing.T) { | |||
| 894 | 846 | for i := 1; i <= count; i++ { | |
| 895 | 847 | acceptor.start(PhysicalStreamID(i), deadline) | |
| 896 | 848 | } | |
| 897 | - | connections := make([]*LogicalConnection, 0, count) | |
| 849 | + | connections := make([]typedLogical, 0, count) | |
| 898 | 850 | for i := 1; i <= count; i++ { | |
| 899 | 851 | connection := openWithDeadline(t, connector, i) | |
| 900 | 852 | 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) { | |||
| 75 | 75 | client, err := pool.RegisterClient() | |
| 76 | 76 | require.NoError(t, err) | |
| 77 | 77 | ||
| 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)) | |
| 79 | 79 | require.NoError(t, err) | |
| 80 | 80 | require.NotNil(t, first) | |
| 81 | 81 | t.Cleanup(func() { _ = first.Close() }) | |
| 82 | 82 | ||
| 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)) | |
| 84 | 84 | require.NoError(t, err) | |
| 85 | 85 | require.NotNil(t, second) | |
| 86 | 86 | t.Cleanup(func() { _ = second.Close() }) | |
| @@ -114,7 +114,7 @@ func TestPoolRefusesConflictingPolicyWithoutDial(t *testing.T) { | |||
| 114 | 114 | ||
| 115 | 115 | client, err := pool.RegisterClient() | |
| 116 | 116 | 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()))) | |
| 118 | 118 | require.Error(t, err) | |
| 119 | 119 | var typed ports.BrokerError | |
| 120 | 120 | require.ErrorAs(t, err, &typed) | |
| @@ -142,7 +142,7 @@ func TestPoolSurfacesPhysicalLossPerStream(t *testing.T) { | |||
| 142 | 142 | ||
| 143 | 143 | client, err := pool.RegisterClient() | |
| 144 | 144 | 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)) | |
| 146 | 146 | require.NoError(t, err) | |
| 147 | 147 | server.awaitAccepted(t, 1) | |
| 148 | 148 | ||
M internal/adapters/daemonmux/quic_carriage_test.go +7 -7
| @@ -195,10 +195,10 @@ func TestQUICCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) { | |||
| 195 | 195 | require.NoError(t, daemon.awaitAdoption(t)) | |
| 196 | 196 | ||
| 197 | 197 | // 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)) | |
| 199 | 199 | require.NoError(t, err) | |
| 200 | 200 | 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)) | |
| 202 | 202 | require.NoError(t, err) | |
| 203 | 203 | t.Cleanup(func() { _ = second.Close() }) | |
| 204 | 204 | daemon.awaitQUICAccepted(t, 2) | |
| @@ -219,7 +219,7 @@ func TestQUICCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) { | |||
| 219 | 219 | wg.Add(1) | |
| 220 | 220 | go func(i int) { | |
| 221 | 221 | 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)) | |
| 223 | 223 | }(i) | |
| 224 | 224 | } | |
| 225 | 225 | wg.Wait() | |
| @@ -375,11 +375,11 @@ func TestQUICCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) { | |||
| 375 | 375 | ||
| 376 | 376 | lost := make([]ports.BrokerLogicalConnection, 3) | |
| 377 | 377 | 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)) | |
| 379 | 379 | require.NoError(t, err, "stream %d", i+1) | |
| 380 | 380 | t.Cleanup(func() { _ = lost[i].Close() }) | |
| 381 | 381 | } | |
| 382 | - | survivor, err := physicalB.OpenStream(context.Background(), muxOpenRequest(1, policy)) | |
| 382 | + | survivor, err := openTyped(physicalB, context.Background(), muxOpenRequest(1, policy)) | |
| 383 | 383 | require.NoError(t, err) | |
| 384 | 384 | t.Cleanup(func() { _ = survivor.Close() }) | |
| 385 | 385 | daemon.awaitQUICAccepted(t, 4) | |
| @@ -429,7 +429,7 @@ func TestQUICCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) { | |||
| 429 | 429 | "the lost QUIC physical child was never reaped") | |
| 430 | 430 | ||
| 431 | 431 | // 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)) | |
| 433 | 433 | require.Error(t, err) | |
| 434 | 434 | } | |
| 435 | 435 | ||
| @@ -455,7 +455,7 @@ func TestQUICCarriageSetupContextDetachedFromPhysicalLifetime(t *testing.T) { | |||
| 455 | 455 | ||
| 456 | 456 | cancel() | |
| 457 | 457 | 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())) | |
| 459 | 459 | require.NoError(t, err) | |
| 460 | 460 | t.Cleanup(func() { _ = logical.Close() }) | |
| 461 | 461 | 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) { | |||
| 253 | 253 | pid := sshMuxReadPID(t, pidPath) | |
| 254 | 254 | ||
| 255 | 255 | // 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)) | |
| 257 | 257 | require.NoError(t, err) | |
| 258 | 258 | 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)) | |
| 260 | 260 | require.NoError(t, err) | |
| 261 | 261 | t.Cleanup(func() { _ = second.Close() }) | |
| 262 | 262 | for _, stream := range []ports.BrokerLogicalConnection{first, second} { | |
| @@ -276,7 +276,7 @@ func TestSSHCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) { | |||
| 276 | 276 | wg.Add(1) | |
| 277 | 277 | go func(i int) { | |
| 278 | 278 | 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)) | |
| 280 | 280 | }(i) | |
| 281 | 281 | } | |
| 282 | 282 | wg.Wait() | |
| @@ -332,12 +332,12 @@ func TestSSHCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) { | |||
| 332 | 332 | ||
| 333 | 333 | lost := make([]ports.BrokerLogicalConnection, 3) | |
| 334 | 334 | 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)) | |
| 336 | 336 | require.NoError(t, err, "stream %d", i+1) | |
| 337 | 337 | lost[i] = connection | |
| 338 | 338 | t.Cleanup(func() { _ = connection.Close() }) | |
| 339 | 339 | } | |
| 340 | - | survivor, err := physicalB.OpenStream(context.Background(), muxOpenRequest(1, policy)) | |
| 340 | + | survivor, err := openTyped(physicalB, context.Background(), muxOpenRequest(1, policy)) | |
| 341 | 341 | require.NoError(t, err) | |
| 342 | 342 | t.Cleanup(func() { _ = survivor.Close() }) | |
| 343 | 343 | ||
| @@ -383,7 +383,7 @@ func TestSSHCarriagePhysicalFailureFansOutAndIsIsolated(t *testing.T) { | |||
| 383 | 383 | require.Equal(t, protocol.Pong{}, message) | |
| 384 | 384 | ||
| 385 | 385 | // 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)) | |
| 387 | 387 | require.Error(t, err) | |
| 388 | 388 | ||
| 389 | 389 | // The failed subprocess is reaped, not left a zombie. | |
| @@ -409,7 +409,7 @@ func TestSSHCarriageSetupContextDetachedFromPhysicalLifetime(t *testing.T) { | |||
| 409 | 409 | cancel() | |
| 410 | 410 | ||
| 411 | 411 | 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())) | |
| 413 | 413 | require.NoError(t, err) | |
| 414 | 414 | t.Cleanup(func() { _ = logical.Close() }) | |
| 415 | 415 | 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) { | |||
| 112 | 112 | require.NoError(t, err) | |
| 113 | 113 | require.NotNil(t, connection) | |
| 114 | 114 | 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() | |
| 117 | 118 | require.NoError(t, err) | |
| 118 | 119 | require.Equal(t, protocol.Pong{}, message) | |
| 119 | 120 | } | |
| @@ -152,7 +153,7 @@ func TestServerSupervisorDeliversFirstHelloDataFrame(t *testing.T) { | |||
| 152 | 153 | accepted <- connection | |
| 153 | 154 | }() | |
| 154 | 155 | ||
| 155 | - | logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 156 | + | logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 156 | 157 | require.NoError(t, err) | |
| 157 | 158 | var server ports.ServerConnection | |
| 158 | 159 | select { | |
| @@ -220,7 +221,7 @@ func TestServerSupervisorStampsAcceptedOriginThroughAggregate(t *testing.T) { | |||
| 220 | 221 | accepted <- connection | |
| 221 | 222 | }() | |
| 222 | 223 | ||
| 223 | - | logical, err := physical.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 224 | + | logical, err := openTyped(physical, context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 224 | 225 | require.NoError(t, err) | |
| 225 | 226 | t.Cleanup(func() { _ = logical.Close() }) | |
| 226 | 227 | ||
| @@ -292,9 +293,9 @@ func TestServerSupervisorServerLossIsolated(t *testing.T) { | |||
| 292 | 293 | physicalB := connectRaw(t, clientB, endpoint) | |
| 293 | 294 | require.NoError(t, server.awaitAdoption(t)) | |
| 294 | 295 | ||
| 295 | - | logicalA, err := physicalA.OpenStream(context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 296 | + | logicalA, err := openTyped(physicalA, context.Background(), muxOpenRequest(1, binding.Policy())) | |
| 296 | 297 | 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())) | |
| 298 | 299 | require.NoError(t, err) | |
| 299 | 300 | server.awaitAccepted(t, 2) | |
| 300 | 301 | require.Equal(t, 2, server.supervisor.Children()) | |
| @@ -307,14 +308,14 @@ func TestServerSupervisorServerLossIsolated(t *testing.T) { | |||
| 307 | 308 | "the lost child was never reaped") | |
| 308 | 309 | ||
| 309 | 310 | // 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())) | |
| 311 | 312 | require.NoError(t, err) | |
| 312 | 313 | require.NotNil(t, logicalB2) | |
| 313 | 314 | server.awaitAccepted(t, 3) | |
| 314 | 315 | ||
| 315 | 316 | // The lost physical refuses a fresh stream while its published logical | |
| 316 | 317 | // 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())) | |
| 318 | 319 | require.Error(t, err) | |
| 319 | 320 | require.True(t, channelClosed(logicalA.Done())) | |
| 320 | 321 | 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) { | |||
| 148 | 148 | require.NoError(t, server.awaitAdoption(t)) | |
| 149 | 149 | ||
| 150 | 150 | // 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)) | |
| 152 | 152 | require.NoError(t, err) | |
| 153 | 153 | 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)) | |
| 155 | 155 | require.NoError(t, err) | |
| 156 | 156 | t.Cleanup(func() { _ = second.Close() }) | |
| 157 | 157 | server.awaitAccepted(t, 2) | |
| @@ -172,7 +172,7 @@ func TestUnixCarriageSupervisorTwoThenHundredTypedAdmissions(t *testing.T) { | |||
| 172 | 172 | wg.Add(1) | |
| 173 | 173 | go func(i int) { | |
| 174 | 174 | 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)) | |
| 176 | 176 | }(i) | |
| 177 | 177 | } | |
| 178 | 178 | 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 ( | |||
| 21 | 21 | "github.com/bnema/vev/internal/adapters/daemonmux" | |
| 22 | 22 | "github.com/bnema/vev/internal/adapters/ipc" | |
| 23 | 23 | "github.com/bnema/vev/internal/adapters/lifecycle" | |
| 24 | + | "github.com/bnema/vev/internal/adapters/sessionwire" | |
| 24 | 25 | "github.com/bnema/vev/internal/logging" | |
| 25 | 26 | "github.com/bnema/vev/internal/platform" | |
| 26 | 27 | "github.com/bnema/vev/internal/ports" | |
| @@ -317,7 +318,7 @@ func runBrokerServe(ctx context.Context, options brokerServeOptions, deps broker | |||
| 317 | 318 | if err != nil { | |
| 318 | 319 | return err | |
| 319 | 320 | } | |
| 320 | - | remoteProbe := &brokerRemoteProbe{epoch: epoch, routes: resolver, connector: connector} | |
| 321 | + | remoteProbe := &brokerRemoteProbe{epoch: epoch, routes: resolver, connector: connector, codec: sessionwire.BrokerCodec{}} | |
| 321 | 322 | registry, err := broker.NewRegistryWithConfig(epoch, store, remoteProbe, clk, log, registryConfig) | |
| 322 | 323 | if err != nil { | |
| 323 | 324 | return err | |
| @@ -345,7 +346,7 @@ func runBrokerServe(ctx context.Context, options brokerServeOptions, deps broker | |||
| 345 | 346 | if err := supervisor.RegisterCloseable("pool", pool); err != nil { | |
| 346 | 347 | return err | |
| 347 | 348 | } | |
| 348 | - | authority, err := broker.NewAuthority(epoch, registry, pool, supervisor) | |
| 349 | + | authority, err := broker.NewAuthority(epoch, registry, pool, supervisor, sessionwire.BrokerCodec{}) | |
| 349 | 350 | if err != nil { | |
| 350 | 351 | return err | |
| 351 | 352 | } | |
M internal/app/broker_offline_local.go +5 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | ||
| 8 | 8 | "github.com/bnema/vev/internal/adapters/brokerconfig" | |
| 9 | 9 | "github.com/bnema/vev/internal/adapters/daemonmux" | |
| 10 | + | "github.com/bnema/vev/internal/adapters/sessionwire" | |
| 10 | 11 | "github.com/bnema/vev/internal/domain" | |
| 11 | 12 | "github.com/bnema/vev/internal/ports" | |
| 12 | 13 | "github.com/bnema/vev/internal/usecase/broker" | |
| @@ -60,6 +61,7 @@ type localRouteProbe struct { | |||
| 60 | 61 | loadIdentity localIdentityLoader | |
| 61 | 62 | connector ports.BrokerEndpointConnector | |
| 62 | 63 | shared pooledPhysicals | |
| 64 | + | codec ports.SessionCodec | |
| 63 | 65 | } | |
| 64 | 66 | ||
| 65 | 67 | var _ broker.LocalProbe = (*localRouteProbe)(nil) | |
| @@ -87,7 +89,7 @@ func newDynamicLocalRouteProbe(route brokerconfig.Route, policy ports.BrokerPoli | |||
| 87 | 89 | if err := policy.Validate(); err != nil { | |
| 88 | 90 | return nil, fmt.Errorf("vev: broker local probe: %w", err) | |
| 89 | 91 | } | |
| 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 | |
| 91 | 93 | } | |
| 92 | 94 | ||
| 93 | 95 | // ProbeLocal observes the local daemon by authenticating the daemonmux physical | |
| @@ -127,7 +129,7 @@ func (p *localRouteProbe) ProbeLocal(ctx context.Context) (ports.BrokerDaemonObs | |||
| 127 | 129 | if err != nil { | |
| 128 | 130 | return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, err | |
| 129 | 131 | } | |
| 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 { | |
| 131 | 133 | if err != nil { | |
| 132 | 134 | return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, err | |
| 133 | 135 | } | |
| @@ -144,7 +146,7 @@ func (p *localRouteProbe) ProbeLocal(ctx context.Context) (ports.BrokerDaemonObs | |||
| 144 | 146 | if physical.Identity() != endpoint.ExpectedIdentity.Identity || !physical.Policy().Compatible(endpoint.Policy) { | |
| 145 | 147 | return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, errors.New("vev: broker local probe authenticated binding mismatch") | |
| 146 | 148 | } | |
| 147 | - | observation, err := observeDaemonCatalogue(ctx, physical, request) | |
| 149 | + | observation, err := observeDaemonCatalogue(ctx, physical, request, p.codec) | |
| 148 | 150 | if err != nil { | |
| 149 | 151 | return ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityUnreachable}, err | |
| 150 | 152 | } | |
M internal/app/broker_offline_local_attach_test.go +12 -2
| @@ -18,6 +18,7 @@ import ( | |||
| 18 | 18 | "github.com/bnema/vev/internal/adapters/daemonmux" | |
| 19 | 19 | "github.com/bnema/vev/internal/adapters/ipc" | |
| 20 | 20 | "github.com/bnema/vev/internal/adapters/pty" | |
| 21 | + | "github.com/bnema/vev/internal/adapters/sessionwire" | |
| 21 | 22 | "github.com/bnema/vev/internal/domain" | |
| 22 | 23 | "github.com/bnema/vev/internal/ports" | |
| 23 | 24 | "github.com/bnema/vev/internal/protocol" | |
| @@ -134,10 +135,19 @@ func (f *realLocalDaemonFixture) openStream(t *testing.T, request ports.BrokerOp | |||
| 134 | 135 | } | |
| 135 | 136 | stream, err := physical.OpenStream(ctx, request) | |
| 136 | 137 | 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 | |
| 139 | 141 | } | |
| 140 | 142 | ||
| 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 | + | ||
| 141 | 151 | // awaitWelcome receives server messages until the typed Welcome arrives. | |
| 142 | 152 | func awaitWelcome(t *testing.T, stream ports.BrokerLogicalConnection) protocol.Welcome { | |
| 143 | 153 | 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 | |||
| 142 | 142 | // fixed terminal error, so a test can drive the accept drain without a carriage. | |
| 143 | 143 | type fatalListener struct{ err error } | |
| 144 | 144 | ||
| 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" } | |
| 148 | 148 | ||
| 149 | 149 | // TestDrainBrokerAcceptClassifiesTerminalFailure proves the drain treats a | |
| 150 | 150 | // listener close as an orderly end with no log and no failure signal, while any | |
| @@ -367,7 +367,7 @@ type wedgedListener struct { | |||
| 367 | 367 | closed atomic.Bool | |
| 368 | 368 | } | |
| 369 | 369 | ||
| 370 | - | func (l *wedgedListener) Accept() (ports.BrokerService, error) { return nil, l.err } | |
| 370 | + | func (l *wedgedListener) Accept() (ports.BrokerCoreService, error) { return nil, l.err } | |
| 371 | 371 | func (l *wedgedListener) Close() error { | |
| 372 | 372 | l.closed.Store(true) | |
| 373 | 373 | return nil | |
M internal/app/broker_remote_probe.go +11 -10
| @@ -36,6 +36,7 @@ type brokerRemoteProbe struct { | |||
| 36 | 36 | connector ports.BrokerEndpointConnector | |
| 37 | 37 | hosts ports.BrokerHostAuthorityReader | |
| 38 | 38 | shared pooledPhysicals | |
| 39 | + | codec ports.SessionCodec | |
| 39 | 40 | } | |
| 40 | 41 | ||
| 41 | 42 | // sharedPhysicals lends the pooled transport of an attached or warm daemon. | |
| @@ -60,7 +61,7 @@ func (s *pooledPhysicals) adopt(physical ports.BrokerPhysicalConnection, policy | |||
| 60 | 61 | } | |
| 61 | 62 | ||
| 62 | 63 | // 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) { | |
| 64 | 65 | pool, _ := s.pool.Load().(sharedPhysicals) | |
| 65 | 66 | if pool == nil || identity == "" { | |
| 66 | 67 | return ports.BrokerDaemonObservation{}, false, nil | |
| @@ -69,7 +70,7 @@ func (s *pooledPhysicals) observe(ctx context.Context, identity ports.BrokerDaem | |||
| 69 | 70 | if !ok { | |
| 70 | 71 | return ports.BrokerDaemonObservation{}, false, nil | |
| 71 | 72 | } | |
| 72 | - | observation, err := observeDaemonCatalogue(ctx, physical, request) | |
| 73 | + | observation, err := observeDaemonCatalogue(ctx, physical, request, codec) | |
| 73 | 74 | if err == nil || ctx.Err() != nil { | |
| 74 | 75 | return observation, true, err | |
| 75 | 76 | } | |
| @@ -99,7 +100,7 @@ func (p *brokerRemoteProbe) Probe(ctx context.Context, registration domain.Remot | |||
| 99 | 100 | // bootstrapping SSH/QUIC again. A borrowed transport that retires mid-probe | |
| 100 | 101 | // falls back to a fresh dial. | |
| 101 | 102 | 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 { | |
| 103 | 104 | return observation, err | |
| 104 | 105 | } | |
| 105 | 106 | } | |
| @@ -127,7 +128,7 @@ func (p *brokerRemoteProbe) Probe(ctx context.Context, registration domain.Remot | |||
| 127 | 128 | if err != nil || identity != physical.Identity() { | |
| 128 | 129 | return ports.BrokerDaemonObservation{}, errors.New("vev: remote probe could not commit authenticated binding") | |
| 129 | 130 | } | |
| 130 | - | observation, err := observeDaemonCatalogue(ctx, physical, request) | |
| 131 | + | observation, err := observeDaemonCatalogue(ctx, physical, request, p.codec) | |
| 131 | 132 | if err == nil && ctx.Err() == nil { | |
| 132 | 133 | adopted = p.shared.adopt(physical, endpoint.Policy) | |
| 133 | 134 | } | |
| @@ -147,8 +148,8 @@ func (p *brokerRemoteProbe) Probe(ctx context.Context, registration domain.Remot | |||
| 147 | 148 | // catalogue, and a catalogue outside the exact current schema all fail closed: | |
| 148 | 149 | // the caller receives an error and no observation it could publish, so a probe | |
| 149 | 150 | // 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 { | |
| 152 | 153 | return ports.BrokerDaemonObservation{}, errors.New("vev: invalid daemon observation request") | |
| 153 | 154 | } | |
| 154 | 155 | logical, err := physical.OpenStream(ctx, request) | |
| @@ -167,7 +168,7 @@ func observeDaemonCatalogue(ctx context.Context, physical ports.BrokerPhysicalCo | |||
| 167 | 168 | if err != nil { | |
| 168 | 169 | return ports.BrokerDaemonObservation{}, err | |
| 169 | 170 | } | |
| 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}) | |
| 171 | 172 | if err != nil { | |
| 172 | 173 | return ports.BrokerDaemonObservation{}, err | |
| 173 | 174 | } | |
| @@ -201,7 +202,7 @@ func observeDaemonCatalogue(ctx context.Context, physical ports.BrokerPhysicalCo | |||
| 201 | 202 | // joined before returning, so an observation always returns promptly once its | |
| 202 | 203 | // attempt is retired instead of parking the daemon's reader (or a probe | |
| 203 | 204 | // 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) { | |
| 205 | 206 | if ctx == nil { | |
| 206 | 207 | ctx = context.Background() | |
| 207 | 208 | } | |
| @@ -211,11 +212,11 @@ func exchangeObservationCommand(ctx context.Context, logical ports.BrokerLogical | |||
| 211 | 212 | } | |
| 212 | 213 | done := make(chan outcome, 1) | |
| 213 | 214 | go func() { | |
| 214 | - | if err := logical.SendClient(command); err != nil { | |
| 215 | + | if err := typed.SendClient(command); err != nil { | |
| 215 | 216 | done <- outcome{err: err} | |
| 216 | 217 | return | |
| 217 | 218 | } | |
| 218 | - | message, err := logical.ReceiveServer() | |
| 219 | + | message, err := typed.ReceiveServer() | |
| 219 | 220 | done <- outcome{message: message, err: err} | |
| 220 | 221 | }() | |
| 221 | 222 | select { | |
M internal/app/broker_remote_probe_shared_test.go +15 -9
| @@ -56,6 +56,7 @@ func TestBrokerRemoteProbeBorrowsWarmTransport(t *testing.T) { | |||
| 56 | 56 | connector.EXPECT().Connect(mock.Anything, mock.Anything).Return(nil, dialErr).Times(tt.wantDials) | |
| 57 | 57 | } | |
| 58 | 58 | physical := portsmocks.NewMockBrokerPhysicalConnection(t) | |
| 59 | + | codec := portsmocks.NewMockSessionCodec(t) | |
| 59 | 60 | done := make(chan struct{}) | |
| 60 | 61 | if tt.retired { | |
| 61 | 62 | close(done) | |
| @@ -67,13 +68,15 @@ func TestBrokerRemoteProbeBorrowsWarmTransport(t *testing.T) { | |||
| 67 | 68 | physical.EXPECT().Done().Return(done) | |
| 68 | 69 | } | |
| 69 | 70 | } else { | |
| 70 | - | logical := portsmocks.NewMockBrokerLogicalConnection(t) | |
| 71 | + | logical := portsmocks.NewMockBrokerEnvelopeStream(t) | |
| 72 | + | typed := portsmocks.NewMockClientConnection(t) | |
| 73 | + | codec.EXPECT().Client(logical).Return(typed) | |
| 71 | 74 | 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 { | |
| 73 | 76 | sent = message.(protocol.CommandRequest) | |
| 74 | 77 | return nil | |
| 75 | 78 | }) | |
| 76 | - | logical.EXPECT().ReceiveServer().RunAndReturn(func() (protocol.ServerMessage, error) { | |
| 79 | + | typed.EXPECT().ReceiveServer().RunAndReturn(func() (protocol.ServerMessage, error) { | |
| 77 | 80 | return protocol.CommandResult{RequestID: sent.RequestID, Outcome: protocol.CommandSucceeded, Output: testLocalCatalogue(t)}, nil | |
| 78 | 81 | }) | |
| 79 | 82 | logical.EXPECT().Close().Return(nil) | |
| @@ -84,7 +87,7 @@ func TestBrokerRemoteProbeBorrowsWarmTransport(t *testing.T) { | |||
| 84 | 87 | } | |
| 85 | 88 | probe := &brokerRemoteProbe{ | |
| 86 | 89 | 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, | |
| 88 | 91 | } | |
| 89 | 92 | // Use the real pool for borrowing. Stateful pool retirement is | |
| 90 | 93 | // covered with a fake physical in broker's worker tests. | |
| @@ -145,6 +148,7 @@ func TestBrokerRemoteProbeSilentBorrowedTransportNeverRedials(t *testing.T) { | |||
| 145 | 148 | // No Connect expectation: any redial fails the mock. | |
| 146 | 149 | connector := portsmocks.NewMockBrokerEndpointConnector(t) | |
| 147 | 150 | physical := portsmocks.NewMockBrokerPhysicalConnection(t) | |
| 151 | + | codec := portsmocks.NewMockSessionCodec(t) | |
| 148 | 152 | healthy := make(chan struct{}) | |
| 149 | 153 | physical.EXPECT().Policy().Return(policy).Maybe() | |
| 150 | 154 | physical.EXPECT().Identity().Return(identity).Maybe() | |
| @@ -158,17 +162,19 @@ func TestBrokerRemoteProbeSilentBorrowedTransportNeverRedials(t *testing.T) { | |||
| 158 | 162 | // worker only signals, the test goroutine cancels and asserts. | |
| 159 | 163 | waiting := make(chan struct{}, 1) | |
| 160 | 164 | 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) { | |
| 162 | 166 | waiting <- struct{}{} | |
| 163 | 167 | <-ctx.Done() | |
| 164 | 168 | return nil, ctx.Err() | |
| 165 | 169 | }) | |
| 166 | 170 | } else { | |
| 167 | - | logical := portsmocks.NewMockBrokerLogicalConnection(t) | |
| 171 | + | logical := portsmocks.NewMockBrokerEnvelopeStream(t) | |
| 172 | + | typed := portsmocks.NewMockClientConnection(t) | |
| 173 | + | codec.EXPECT().Client(logical).Return(typed) | |
| 168 | 174 | closed := make(chan struct{}) | |
| 169 | 175 | 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) { | |
| 172 | 178 | waiting <- struct{}{} | |
| 173 | 179 | <-closed | |
| 174 | 180 | return nil, errors.New("stream closed") | |
| @@ -178,7 +184,7 @@ func TestBrokerRemoteProbeSilentBorrowedTransportNeverRedials(t *testing.T) { | |||
| 178 | 184 | } | |
| 179 | 185 | probe := &brokerRemoteProbe{ | |
| 180 | 186 | 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, | |
| 182 | 188 | } | |
| 183 | 189 | pool, err := broker.NewPool(7, routes, probe.binder, connector, clock.New(), broker.PoolLimits{Physical: 1, Clients: 1, Streams: 2, StreamsPerClient: 2, Warm: 1}) | |
| 184 | 190 | require.NoError(t, err) | |
M internal/ports/broker.go +30 -5
| @@ -823,7 +823,7 @@ type BrokerPreviewSubscription interface { | |||
| 823 | 823 | // local and remote daemons through it, including the local daemon. | |
| 824 | 824 | // Snapshot access performs no I/O; request methods are non-blocking | |
| 825 | 825 | // coalesced hints except where the context explicitly bounds them. | |
| 826 | - | type BrokerService interface { | |
| 826 | + | type BrokerSession interface { | |
| 827 | 827 | // ConnectionID returns the ID assigned when this client connection was | |
| 828 | 828 | // accepted. Clients carry it on stream operations to fence stale requests. | |
| 829 | 829 | ConnectionID() BrokerConnectionID | |
| @@ -844,7 +844,6 @@ type BrokerService interface { | |||
| 844 | 844 | Snapshot() BrokerSnapshot | |
| 845 | 845 | Subscribe() (BrokerSubscription, error) | |
| 846 | 846 | SubscribePreview(request BrokerPreviewRequest) (BrokerPreviewSubscription, error) | |
| 847 | - | OpenStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerLogicalConnection, error) | |
| 848 | 847 | CloseStream(connection BrokerConnectionID, stream BrokerStreamID) error | |
| 849 | 848 | // AddHost durably adds or pins endpoint under policy and returns its authority. | |
| 850 | 849 | AddHost(ctx context.Context, endpoint string, policy BrokerPolicy) (domain.RemoteRegistration, error) | |
| @@ -856,6 +855,32 @@ type BrokerService interface { | |||
| 856 | 855 | Close() error | |
| 857 | 856 | } | |
| 858 | 857 | ||
| 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 | + | ||
| 859 | 884 | // BrokerSnapshotStore persists the durable broker snapshot independently | |
| 860 | 885 | // from session state. The broker is its sole writer; session persistence | |
| 861 | 886 | // stays daemon-owned and is never moved here. Load is called once while the | |
| @@ -910,7 +935,7 @@ type BrokerPhysicalConnection interface { | |||
| 910 | 935 | Identity() BrokerDaemonIdentity | |
| 911 | 936 | Incarnation() BrokerDaemonIncarnation | |
| 912 | 937 | Policy() BrokerPolicy | |
| 913 | - | OpenStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerLogicalConnection, error) | |
| 938 | + | OpenStream(ctx context.Context, request BrokerOpenStreamRequest) (BrokerEnvelopeStream, error) | |
| 914 | 939 | Close() error | |
| 915 | 940 | } | |
| 916 | 941 | ||
| @@ -961,7 +986,7 @@ type BrokerConnector interface { | |||
| 961 | 986 | // parked in admission immediately. The admitted service gets its own | |
| 962 | 987 | // connection-lived context and must not derive from this one. | |
| 963 | 988 | type BrokerAuthority interface { | |
| 964 | - | AdmitClient(ctx context.Context) (BrokerService, error) | |
| 989 | + | AdmitClient(ctx context.Context) (BrokerCoreService, error) | |
| 965 | 990 | } | |
| 966 | 991 | ||
| 967 | 992 | // BrokerListener accepts client connections to the per-user broker | |
| @@ -972,7 +997,7 @@ type BrokerAuthority interface { | |||
| 972 | 997 | // Implementations own the owner-only directory/socket, peer credential | |
| 973 | 998 | // checks, bounded clients and queues, and cancellation-safe accept loops. | |
| 974 | 999 | type BrokerListener interface { | |
| 975 | - | Accept() (BrokerService, error) | |
| 1000 | + | Accept() (BrokerCoreService, error) | |
| 976 | 1001 | Close() error | |
| 977 | 1002 | Addr() string | |
| 978 | 1003 | } | |
M internal/ports/mocks/broker_mock.go +2036 -165
| @@ -268,13 +268,1804 @@ func (_c *MockBrokerPreviewSubscription_Latest_Call) RunAndReturn(run func() por | |||
| 268 | 268 | return _c | |
| 269 | 269 | } | |
| 270 | 270 | ||
| 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 | + | ||
| 271 | 999 | // 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. | |
| 272 | 1000 | // 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 { | |
| 274 | 2065 | mock.TestingT | |
| 275 | 2066 | Cleanup(func()) | |
| 276 | - | }) *MockBrokerService { | |
| 277 | - | mock := &MockBrokerService{} | |
| 2067 | + | }) *MockBrokerCoreService { | |
| 2068 | + | mock := &MockBrokerCoreService{} | |
| 278 | 2069 | mock.Mock.Test(t) | |
| 279 | 2070 | ||
| 280 | 2071 | t.Cleanup(func() { mock.AssertExpectations(t) }) | |
| @@ -282,21 +2073,21 @@ func NewMockBrokerService(t interface { | |||
| 282 | 2073 | return mock | |
| 283 | 2074 | } | |
| 284 | 2075 | ||
| 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 { | |
| 287 | 2078 | mock.Mock | |
| 288 | 2079 | } | |
| 289 | 2080 | ||
| 290 | - | type MockBrokerService_Expecter struct { | |
| 2081 | + | type MockBrokerCoreService_Expecter struct { | |
| 291 | 2082 | mock *mock.Mock | |
| 292 | 2083 | } | |
| 293 | 2084 | ||
| 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} | |
| 296 | 2087 | } | |
| 297 | 2088 | ||
| 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) { | |
| 300 | 2091 | ret := _mock.Called(ctx, endpoint, policy) | |
| 301 | 2092 | ||
| 302 | 2093 | if len(ret) == 0 { | |
| @@ -321,8 +2112,8 @@ func (_mock *MockBrokerService) AddHost(ctx context.Context, endpoint string, po | |||
| 321 | 2112 | return r0, r1 | |
| 322 | 2113 | } | |
| 323 | 2114 | ||
| 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 { | |
| 326 | 2117 | *mock.Call | |
| 327 | 2118 | } | |
| 328 | 2119 | ||
| @@ -330,11 +2121,11 @@ type MockBrokerService_AddHost_Call struct { | |||
| 330 | 2121 | // - ctx context.Context | |
| 331 | 2122 | // - endpoint string | |
| 332 | 2123 | // - 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)} | |
| 335 | 2126 | } | |
| 336 | 2127 | ||
| 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 { | |
| 338 | 2129 | _c.Call.Run(func(args mock.Arguments) { | |
| 339 | 2130 | var arg0 context.Context | |
| 340 | 2131 | if args[0] != nil { | |
| @@ -357,18 +2148,18 @@ func (_c *MockBrokerService_AddHost_Call) Run(run func(ctx context.Context, endp | |||
| 357 | 2148 | return _c | |
| 358 | 2149 | } | |
| 359 | 2150 | ||
| 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 { | |
| 361 | 2152 | _c.Call.Return(remoteRegistration, err) | |
| 362 | 2153 | return _c | |
| 363 | 2154 | } | |
| 364 | 2155 | ||
| 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 { | |
| 366 | 2157 | _c.Call.Return(run) | |
| 367 | 2158 | return _c | |
| 368 | 2159 | } | |
| 369 | 2160 | ||
| 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 { | |
| 372 | 2163 | ret := _mock.Called() | |
| 373 | 2164 | ||
| 374 | 2165 | if len(ret) == 0 { | |
| @@ -384,35 +2175,35 @@ func (_mock *MockBrokerService) Close() error { | |||
| 384 | 2175 | return r0 | |
| 385 | 2176 | } | |
| 386 | 2177 | ||
| 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 { | |
| 389 | 2180 | *mock.Call | |
| 390 | 2181 | } | |
| 391 | 2182 | ||
| 392 | 2183 | // 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")} | |
| 395 | 2186 | } | |
| 396 | 2187 | ||
| 397 | - | func (_c *MockBrokerService_Close_Call) Run(run func()) *MockBrokerService_Close_Call { | |
| 2188 | + | func (_c *MockBrokerCoreService_Close_Call) Run(run func()) *MockBrokerCoreService_Close_Call { | |
| 398 | 2189 | _c.Call.Run(func(args mock.Arguments) { | |
| 399 | 2190 | run() | |
| 400 | 2191 | }) | |
| 401 | 2192 | return _c | |
| 402 | 2193 | } | |
| 403 | 2194 | ||
| 404 | - | func (_c *MockBrokerService_Close_Call) Return(err error) *MockBrokerService_Close_Call { | |
| 2195 | + | func (_c *MockBrokerCoreService_Close_Call) Return(err error) *MockBrokerCoreService_Close_Call { | |
| 405 | 2196 | _c.Call.Return(err) | |
| 406 | 2197 | return _c | |
| 407 | 2198 | } | |
| 408 | 2199 | ||
| 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 { | |
| 410 | 2201 | _c.Call.Return(run) | |
| 411 | 2202 | return _c | |
| 412 | 2203 | } | |
| 413 | 2204 | ||
| 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 { | |
| 416 | 2207 | ret := _mock.Called(connection, stream) | |
| 417 | 2208 | ||
| 418 | 2209 | if len(ret) == 0 { | |
| @@ -428,19 +2219,19 @@ func (_mock *MockBrokerService) CloseStream(connection ports.BrokerConnectionID, | |||
| 428 | 2219 | return r0 | |
| 429 | 2220 | } | |
| 430 | 2221 | ||
| 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 { | |
| 433 | 2224 | *mock.Call | |
| 434 | 2225 | } | |
| 435 | 2226 | ||
| 436 | 2227 | // CloseStream is a helper method to define mock.On call | |
| 437 | 2228 | // - connection ports.BrokerConnectionID | |
| 438 | 2229 | // - 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)} | |
| 441 | 2232 | } | |
| 442 | 2233 | ||
| 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 { | |
| 444 | 2235 | _c.Call.Run(func(args mock.Arguments) { | |
| 445 | 2236 | var arg0 ports.BrokerConnectionID | |
| 446 | 2237 | if args[0] != nil { | |
| @@ -458,18 +2249,18 @@ func (_c *MockBrokerService_CloseStream_Call) Run(run func(connection ports.Brok | |||
| 458 | 2249 | return _c | |
| 459 | 2250 | } | |
| 460 | 2251 | ||
| 461 | - | func (_c *MockBrokerService_CloseStream_Call) Return(err error) *MockBrokerService_CloseStream_Call { | |
| 2252 | + | func (_c *MockBrokerCoreService_CloseStream_Call) Return(err error) *MockBrokerCoreService_CloseStream_Call { | |
| 462 | 2253 | _c.Call.Return(err) | |
| 463 | 2254 | return _c | |
| 464 | 2255 | } | |
| 465 | 2256 | ||
| 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 { | |
| 467 | 2258 | _c.Call.Return(run) | |
| 468 | 2259 | return _c | |
| 469 | 2260 | } | |
| 470 | 2261 | ||
| 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 { | |
| 473 | 2264 | ret := _mock.Called() | |
| 474 | 2265 | ||
| 475 | 2266 | if len(ret) == 0 { | |
| @@ -487,35 +2278,35 @@ func (_mock *MockBrokerService) ConnectionID() ports.BrokerConnectionID { | |||
| 487 | 2278 | return r0 | |
| 488 | 2279 | } | |
| 489 | 2280 | ||
| 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 { | |
| 492 | 2283 | *mock.Call | |
| 493 | 2284 | } | |
| 494 | 2285 | ||
| 495 | 2286 | // 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")} | |
| 498 | 2289 | } | |
| 499 | 2290 | ||
| 500 | - | func (_c *MockBrokerService_ConnectionID_Call) Run(run func()) *MockBrokerService_ConnectionID_Call { | |
| 2291 | + | func (_c *MockBrokerCoreService_ConnectionID_Call) Run(run func()) *MockBrokerCoreService_ConnectionID_Call { | |
| 501 | 2292 | _c.Call.Run(func(args mock.Arguments) { | |
| 502 | 2293 | run() | |
| 503 | 2294 | }) | |
| 504 | 2295 | return _c | |
| 505 | 2296 | } | |
| 506 | 2297 | ||
| 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 { | |
| 508 | 2299 | _c.Call.Return(brokerConnectionID) | |
| 509 | 2300 | return _c | |
| 510 | 2301 | } | |
| 511 | 2302 | ||
| 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 { | |
| 513 | 2304 | _c.Call.Return(run) | |
| 514 | 2305 | return _c | |
| 515 | 2306 | } | |
| 516 | 2307 | ||
| 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{} { | |
| 519 | 2310 | ret := _mock.Called() | |
| 520 | 2311 | ||
| 521 | 2312 | if len(ret) == 0 { | |
| @@ -533,35 +2324,35 @@ func (_mock *MockBrokerService) Done() <-chan struct{} { | |||
| 533 | 2324 | return r0 | |
| 534 | 2325 | } | |
| 535 | 2326 | ||
| 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 { | |
| 538 | 2329 | *mock.Call | |
| 539 | 2330 | } | |
| 540 | 2331 | ||
| 541 | 2332 | // 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")} | |
| 544 | 2335 | } | |
| 545 | 2336 | ||
| 546 | - | func (_c *MockBrokerService_Done_Call) Run(run func()) *MockBrokerService_Done_Call { | |
| 2337 | + | func (_c *MockBrokerCoreService_Done_Call) Run(run func()) *MockBrokerCoreService_Done_Call { | |
| 547 | 2338 | _c.Call.Run(func(args mock.Arguments) { | |
| 548 | 2339 | run() | |
| 549 | 2340 | }) | |
| 550 | 2341 | return _c | |
| 551 | 2342 | } | |
| 552 | 2343 | ||
| 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 { | |
| 554 | 2345 | _c.Call.Return(valCh) | |
| 555 | 2346 | return _c | |
| 556 | 2347 | } | |
| 557 | 2348 | ||
| 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 { | |
| 559 | 2350 | _c.Call.Return(run) | |
| 560 | 2351 | return _c | |
| 561 | 2352 | } | |
| 562 | 2353 | ||
| 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 { | |
| 565 | 2356 | ret := _mock.Called() | |
| 566 | 2357 | ||
| 567 | 2358 | if len(ret) == 0 { | |
| @@ -577,35 +2368,35 @@ func (_mock *MockBrokerService) Err() error { | |||
| 577 | 2368 | return r0 | |
| 578 | 2369 | } | |
| 579 | 2370 | ||
| 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 { | |
| 582 | 2373 | *mock.Call | |
| 583 | 2374 | } | |
| 584 | 2375 | ||
| 585 | 2376 | // 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")} | |
| 588 | 2379 | } | |
| 589 | 2380 | ||
| 590 | - | func (_c *MockBrokerService_Err_Call) Run(run func()) *MockBrokerService_Err_Call { | |
| 2381 | + | func (_c *MockBrokerCoreService_Err_Call) Run(run func()) *MockBrokerCoreService_Err_Call { | |
| 591 | 2382 | _c.Call.Run(func(args mock.Arguments) { | |
| 592 | 2383 | run() | |
| 593 | 2384 | }) | |
| 594 | 2385 | return _c | |
| 595 | 2386 | } | |
| 596 | 2387 | ||
| 597 | - | func (_c *MockBrokerService_Err_Call) Return(err error) *MockBrokerService_Err_Call { | |
| 2388 | + | func (_c *MockBrokerCoreService_Err_Call) Return(err error) *MockBrokerCoreService_Err_Call { | |
| 598 | 2389 | _c.Call.Return(err) | |
| 599 | 2390 | return _c | |
| 600 | 2391 | } | |
| 601 | 2392 | ||
| 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 { | |
| 603 | 2394 | _c.Call.Return(run) | |
| 604 | 2395 | return _c | |
| 605 | 2396 | } | |
| 606 | 2397 | ||
| 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) { | |
| 609 | 2400 | ret := _mock.Called() | |
| 610 | 2401 | ||
| 611 | 2402 | if len(ret) == 0 { | |
| @@ -630,51 +2421,51 @@ func (_mock *MockBrokerService) NextStreamID() (ports.BrokerStreamID, error) { | |||
| 630 | 2421 | return r0, r1 | |
| 631 | 2422 | } | |
| 632 | 2423 | ||
| 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 { | |
| 635 | 2426 | *mock.Call | |
| 636 | 2427 | } | |
| 637 | 2428 | ||
| 638 | 2429 | // 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")} | |
| 641 | 2432 | } | |
| 642 | 2433 | ||
| 643 | - | func (_c *MockBrokerService_NextStreamID_Call) Run(run func()) *MockBrokerService_NextStreamID_Call { | |
| 2434 | + | func (_c *MockBrokerCoreService_NextStreamID_Call) Run(run func()) *MockBrokerCoreService_NextStreamID_Call { | |
| 644 | 2435 | _c.Call.Run(func(args mock.Arguments) { | |
| 645 | 2436 | run() | |
| 646 | 2437 | }) | |
| 647 | 2438 | return _c | |
| 648 | 2439 | } | |
| 649 | 2440 | ||
| 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 { | |
| 651 | 2442 | _c.Call.Return(brokerStreamID, err) | |
| 652 | 2443 | return _c | |
| 653 | 2444 | } | |
| 654 | 2445 | ||
| 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 { | |
| 656 | 2447 | _c.Call.Return(run) | |
| 657 | 2448 | return _c | |
| 658 | 2449 | } | |
| 659 | 2450 | ||
| 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) { | |
| 662 | 2453 | ret := _mock.Called(ctx, request) | |
| 663 | 2454 | ||
| 664 | 2455 | if len(ret) == 0 { | |
| 665 | - | panic("no return value specified for OpenStream") | |
| 2456 | + | panic("no return value specified for OpenEnvelopeStream") | |
| 666 | 2457 | } | |
| 667 | 2458 | ||
| 668 | - | var r0 ports.BrokerLogicalConnection | |
| 2459 | + | var r0 ports.BrokerEnvelopeStream | |
| 669 | 2460 | 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 { | |
| 671 | 2462 | return returnFunc(ctx, request) | |
| 672 | 2463 | } | |
| 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 { | |
| 674 | 2465 | r0 = returnFunc(ctx, request) | |
| 675 | 2466 | } else { | |
| 676 | 2467 | if ret.Get(0) != nil { | |
| 677 | - | r0 = ret.Get(0).(ports.BrokerLogicalConnection) | |
| 2468 | + | r0 = ret.Get(0).(ports.BrokerEnvelopeStream) | |
| 678 | 2469 | } | |
| 679 | 2470 | } | |
| 680 | 2471 | 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 | |||
| 685 | 2476 | return r0, r1 | |
| 686 | 2477 | } | |
| 687 | 2478 | ||
| 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 { | |
| 690 | 2481 | *mock.Call | |
| 691 | 2482 | } | |
| 692 | 2483 | ||
| 693 | - | // OpenStream is a helper method to define mock.On call | |
| 2484 | + | // OpenEnvelopeStream is a helper method to define mock.On call | |
| 694 | 2485 | // - ctx context.Context | |
| 695 | 2486 | // - 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)} | |
| 698 | 2489 | } | |
| 699 | 2490 | ||
| 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 { | |
| 701 | 2492 | _c.Call.Run(func(args mock.Arguments) { | |
| 702 | 2493 | var arg0 context.Context | |
| 703 | 2494 | if args[0] != nil { | |
| @@ -715,18 +2506,18 @@ func (_c *MockBrokerService_OpenStream_Call) Run(run func(ctx context.Context, r | |||
| 715 | 2506 | return _c | |
| 716 | 2507 | } | |
| 717 | 2508 | ||
| 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) | |
| 720 | 2511 | return _c | |
| 721 | 2512 | } | |
| 722 | 2513 | ||
| 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 { | |
| 724 | 2515 | _c.Call.Return(run) | |
| 725 | 2516 | return _c | |
| 726 | 2517 | } | |
| 727 | 2518 | ||
| 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) { | |
| 730 | 2521 | ret := _mock.Called(ctx, expected) | |
| 731 | 2522 | ||
| 732 | 2523 | if len(ret) == 0 { | |
| @@ -751,19 +2542,19 @@ func (_mock *MockBrokerService) RemoveHost(ctx context.Context, expected domain. | |||
| 751 | 2542 | return r0, r1 | |
| 752 | 2543 | } | |
| 753 | 2544 | ||
| 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 { | |
| 756 | 2547 | *mock.Call | |
| 757 | 2548 | } | |
| 758 | 2549 | ||
| 759 | 2550 | // RemoveHost is a helper method to define mock.On call | |
| 760 | 2551 | // - ctx context.Context | |
| 761 | 2552 | // - 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)} | |
| 764 | 2555 | } | |
| 765 | 2556 | ||
| 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 { | |
| 767 | 2558 | _c.Call.Run(func(args mock.Arguments) { | |
| 768 | 2559 | var arg0 context.Context | |
| 769 | 2560 | if args[0] != nil { | |
| @@ -781,34 +2572,34 @@ func (_c *MockBrokerService_RemoveHost_Call) Run(run func(ctx context.Context, e | |||
| 781 | 2572 | return _c | |
| 782 | 2573 | } | |
| 783 | 2574 | ||
| 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 { | |
| 785 | 2576 | _c.Call.Return(b, err) | |
| 786 | 2577 | return _c | |
| 787 | 2578 | } | |
| 788 | 2579 | ||
| 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 { | |
| 790 | 2581 | _c.Call.Return(run) | |
| 791 | 2582 | return _c | |
| 792 | 2583 | } | |
| 793 | 2584 | ||
| 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) { | |
| 796 | 2587 | _mock.Called(endpoint) | |
| 797 | 2588 | return | |
| 798 | 2589 | } | |
| 799 | 2590 | ||
| 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 { | |
| 802 | 2593 | *mock.Call | |
| 803 | 2594 | } | |
| 804 | 2595 | ||
| 805 | 2596 | // RequestReconcile is a helper method to define mock.On call | |
| 806 | 2597 | // - 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)} | |
| 809 | 2600 | } | |
| 810 | 2601 | ||
| 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 { | |
| 812 | 2603 | _c.Call.Run(func(args mock.Arguments) { | |
| 813 | 2604 | var arg0 string | |
| 814 | 2605 | if args[0] != nil { | |
| @@ -821,18 +2612,18 @@ func (_c *MockBrokerService_RequestReconcile_Call) Run(run func(endpoint string) | |||
| 821 | 2612 | return _c | |
| 822 | 2613 | } | |
| 823 | 2614 | ||
| 824 | - | func (_c *MockBrokerService_RequestReconcile_Call) Return() *MockBrokerService_RequestReconcile_Call { | |
| 2615 | + | func (_c *MockBrokerCoreService_RequestReconcile_Call) Return() *MockBrokerCoreService_RequestReconcile_Call { | |
| 825 | 2616 | _c.Call.Return() | |
| 826 | 2617 | return _c | |
| 827 | 2618 | } | |
| 828 | 2619 | ||
| 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 { | |
| 830 | 2621 | _c.Run(run) | |
| 831 | 2622 | return _c | |
| 832 | 2623 | } | |
| 833 | 2624 | ||
| 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 { | |
| 836 | 2627 | ret := _mock.Called() | |
| 837 | 2628 | ||
| 838 | 2629 | if len(ret) == 0 { | |
| @@ -848,35 +2639,35 @@ func (_mock *MockBrokerService) Snapshot() ports.BrokerSnapshot { | |||
| 848 | 2639 | return r0 | |
| 849 | 2640 | } | |
| 850 | 2641 | ||
| 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 { | |
| 853 | 2644 | *mock.Call | |
| 854 | 2645 | } | |
| 855 | 2646 | ||
| 856 | 2647 | // 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")} | |
| 859 | 2650 | } | |
| 860 | 2651 | ||
| 861 | - | func (_c *MockBrokerService_Snapshot_Call) Run(run func()) *MockBrokerService_Snapshot_Call { | |
| 2652 | + | func (_c *MockBrokerCoreService_Snapshot_Call) Run(run func()) *MockBrokerCoreService_Snapshot_Call { | |
| 862 | 2653 | _c.Call.Run(func(args mock.Arguments) { | |
| 863 | 2654 | run() | |
| 864 | 2655 | }) | |
| 865 | 2656 | return _c | |
| 866 | 2657 | } | |
| 867 | 2658 | ||
| 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 { | |
| 869 | 2660 | _c.Call.Return(brokerSnapshot) | |
| 870 | 2661 | return _c | |
| 871 | 2662 | } | |
| 872 | 2663 | ||
| 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 { | |
| 874 | 2665 | _c.Call.Return(run) | |
| 875 | 2666 | return _c | |
| 876 | 2667 | } | |
| 877 | 2668 | ||
| 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) { | |
| 880 | 2671 | ret := _mock.Called() | |
| 881 | 2672 | ||
| 882 | 2673 | if len(ret) == 0 { | |
| @@ -903,35 +2694,35 @@ func (_mock *MockBrokerService) Subscribe() (ports.BrokerSubscription, error) { | |||
| 903 | 2694 | return r0, r1 | |
| 904 | 2695 | } | |
| 905 | 2696 | ||
| 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 { | |
| 908 | 2699 | *mock.Call | |
| 909 | 2700 | } | |
| 910 | 2701 | ||
| 911 | 2702 | // 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")} | |
| 914 | 2705 | } | |
| 915 | 2706 | ||
| 916 | - | func (_c *MockBrokerService_Subscribe_Call) Run(run func()) *MockBrokerService_Subscribe_Call { | |
| 2707 | + | func (_c *MockBrokerCoreService_Subscribe_Call) Run(run func()) *MockBrokerCoreService_Subscribe_Call { | |
| 917 | 2708 | _c.Call.Run(func(args mock.Arguments) { | |
| 918 | 2709 | run() | |
| 919 | 2710 | }) | |
| 920 | 2711 | return _c | |
| 921 | 2712 | } | |
| 922 | 2713 | ||
| 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 { | |
| 924 | 2715 | _c.Call.Return(brokerSubscription, err) | |
| 925 | 2716 | return _c | |
| 926 | 2717 | } | |
| 927 | 2718 | ||
| 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 { | |
| 929 | 2720 | _c.Call.Return(run) | |
| 930 | 2721 | return _c | |
| 931 | 2722 | } | |
| 932 | 2723 | ||
| 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) { | |
| 935 | 2726 | ret := _mock.Called(request) | |
| 936 | 2727 | ||
| 937 | 2728 | if len(ret) == 0 { | |
| @@ -958,18 +2749,18 @@ func (_mock *MockBrokerService) SubscribePreview(request ports.BrokerPreviewRequ | |||
| 958 | 2749 | return r0, r1 | |
| 959 | 2750 | } | |
| 960 | 2751 | ||
| 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 { | |
| 963 | 2754 | *mock.Call | |
| 964 | 2755 | } | |
| 965 | 2756 | ||
| 966 | 2757 | // SubscribePreview is a helper method to define mock.On call | |
| 967 | 2758 | // - 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)} | |
| 970 | 2761 | } | |
| 971 | 2762 | ||
| 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 { | |
| 973 | 2764 | _c.Call.Run(func(args mock.Arguments) { | |
| 974 | 2765 | var arg0 ports.BrokerPreviewRequest | |
| 975 | 2766 | if args[0] != nil { | |
| @@ -982,18 +2773,18 @@ func (_c *MockBrokerService_SubscribePreview_Call) Run(run func(request ports.Br | |||
| 982 | 2773 | return _c | |
| 983 | 2774 | } | |
| 984 | 2775 | ||
| 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 { | |
| 986 | 2777 | _c.Call.Return(brokerPreviewSubscription, err) | |
| 987 | 2778 | return _c | |
| 988 | 2779 | } | |
| 989 | 2780 | ||
| 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 { | |
| 991 | 2782 | _c.Call.Return(run) | |
| 992 | 2783 | return _c | |
| 993 | 2784 | } | |
| 994 | 2785 | ||
| 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) { | |
| 997 | 2788 | ret := _mock.Called(ctx, expected, policy) | |
| 998 | 2789 | ||
| 999 | 2790 | if len(ret) == 0 { | |
| @@ -1018,8 +2809,8 @@ func (_mock *MockBrokerService) UpdateHostPolicy(ctx context.Context, expected d | |||
| 1018 | 2809 | return r0, r1 | |
| 1019 | 2810 | } | |
| 1020 | 2811 | ||
| 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 { | |
| 1023 | 2814 | *mock.Call | |
| 1024 | 2815 | } | |
| 1025 | 2816 | ||
| @@ -1027,11 +2818,11 @@ type MockBrokerService_UpdateHostPolicy_Call struct { | |||
| 1027 | 2818 | // - ctx context.Context | |
| 1028 | 2819 | // - expected domain.RemoteRegistration | |
| 1029 | 2820 | // - 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)} | |
| 1032 | 2823 | } | |
| 1033 | 2824 | ||
| 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 { | |
| 1035 | 2826 | _c.Call.Run(func(args mock.Arguments) { | |
| 1036 | 2827 | var arg0 context.Context | |
| 1037 | 2828 | if args[0] != nil { | |
| @@ -1054,12 +2845,92 @@ func (_c *MockBrokerService_UpdateHostPolicy_Call) Run(run func(ctx context.Cont | |||
| 1054 | 2845 | return _c | |
| 1055 | 2846 | } | |
| 1056 | 2847 | ||
| 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 { | |
| 1058 | 2849 | _c.Call.Return(remoteRegistration, err) | |
| 1059 | 2850 | return _c | |
| 1060 | 2851 | } | |
| 1061 | 2852 | ||
| 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 { | |
| 1063 | 2934 | _c.Call.Return(run) | |
| 1064 | 2935 | return _c | |
| 1065 | 2936 | } | |
| @@ -1584,23 +3455,23 @@ func (_c *MockBrokerPhysicalConnection_Incarnation_Call) RunAndReturn(run func() | |||
| 1584 | 3455 | } | |
| 1585 | 3456 | ||
| 1586 | 3457 | // 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) { | |
| 1588 | 3459 | ret := _mock.Called(ctx, request) | |
| 1589 | 3460 | ||
| 1590 | 3461 | if len(ret) == 0 { | |
| 1591 | 3462 | panic("no return value specified for OpenStream") | |
| 1592 | 3463 | } | |
| 1593 | 3464 | ||
| 1594 | - | var r0 ports.BrokerLogicalConnection | |
| 3465 | + | var r0 ports.BrokerEnvelopeStream | |
| 1595 | 3466 | 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 { | |
| 1597 | 3468 | return returnFunc(ctx, request) | |
| 1598 | 3469 | } | |
| 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 { | |
| 1600 | 3471 | r0 = returnFunc(ctx, request) | |
| 1601 | 3472 | } else { | |
| 1602 | 3473 | if ret.Get(0) != nil { | |
| 1603 | - | r0 = ret.Get(0).(ports.BrokerLogicalConnection) | |
| 3474 | + | r0 = ret.Get(0).(ports.BrokerEnvelopeStream) | |
| 1604 | 3475 | } | |
| 1605 | 3476 | } | |
| 1606 | 3477 | 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 | |||
| 1641 | 3512 | return _c | |
| 1642 | 3513 | } | |
| 1643 | 3514 | ||
| 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) | |
| 1646 | 3517 | return _c | |
| 1647 | 3518 | } | |
| 1648 | 3519 | ||
| 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 { | |
| 1650 | 3521 | _c.Call.Return(run) | |
| 1651 | 3522 | return _c | |
| 1652 | 3523 | } | |
| @@ -1907,23 +3778,23 @@ func (_m *MockBrokerAuthority) EXPECT() *MockBrokerAuthority_Expecter { | |||
| 1907 | 3778 | } | |
| 1908 | 3779 | ||
| 1909 | 3780 | // 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) { | |
| 1911 | 3782 | ret := _mock.Called(ctx) | |
| 1912 | 3783 | ||
| 1913 | 3784 | if len(ret) == 0 { | |
| 1914 | 3785 | panic("no return value specified for AdmitClient") | |
| 1915 | 3786 | } | |
| 1916 | 3787 | ||
| 1917 | - | var r0 ports.BrokerService | |
| 3788 | + | var r0 ports.BrokerCoreService | |
| 1918 | 3789 | 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 { | |
| 1920 | 3791 | return returnFunc(ctx) | |
| 1921 | 3792 | } | |
| 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 { | |
| 1923 | 3794 | r0 = returnFunc(ctx) | |
| 1924 | 3795 | } else { | |
| 1925 | 3796 | if ret.Get(0) != nil { | |
| 1926 | - | r0 = ret.Get(0).(ports.BrokerService) | |
| 3797 | + | r0 = ret.Get(0).(ports.BrokerCoreService) | |
| 1927 | 3798 | } | |
| 1928 | 3799 | } | |
| 1929 | 3800 | 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 | |||
| 1958 | 3829 | return _c | |
| 1959 | 3830 | } | |
| 1960 | 3831 | ||
| 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) | |
| 1963 | 3834 | return _c | |
| 1964 | 3835 | } | |
| 1965 | 3836 | ||
| 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 { | |
| 1967 | 3838 | _c.Call.Return(run) | |
| 1968 | 3839 | return _c | |
| 1969 | 3840 | } | |
| @@ -1996,23 +3867,23 @@ func (_m *MockBrokerListener) EXPECT() *MockBrokerListener_Expecter { | |||
| 1996 | 3867 | } | |
| 1997 | 3868 | ||
| 1998 | 3869 | // 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) { | |
| 2000 | 3871 | ret := _mock.Called() | |
| 2001 | 3872 | ||
| 2002 | 3873 | if len(ret) == 0 { | |
| 2003 | 3874 | panic("no return value specified for Accept") | |
| 2004 | 3875 | } | |
| 2005 | 3876 | ||
| 2006 | - | var r0 ports.BrokerService | |
| 3877 | + | var r0 ports.BrokerCoreService | |
| 2007 | 3878 | 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 { | |
| 2009 | 3880 | return returnFunc() | |
| 2010 | 3881 | } | |
| 2011 | - | if returnFunc, ok := ret.Get(0).(func() ports.BrokerService); ok { | |
| 3882 | + | if returnFunc, ok := ret.Get(0).(func() ports.BrokerCoreService); ok { | |
| 2012 | 3883 | r0 = returnFunc() | |
| 2013 | 3884 | } else { | |
| 2014 | 3885 | if ret.Get(0) != nil { | |
| 2015 | - | r0 = ret.Get(0).(ports.BrokerService) | |
| 3886 | + | r0 = ret.Get(0).(ports.BrokerCoreService) | |
| 2016 | 3887 | } | |
| 2017 | 3888 | } | |
| 2018 | 3889 | if returnFunc, ok := ret.Get(1).(func() error); ok { | |
| @@ -2040,12 +3911,12 @@ func (_c *MockBrokerListener_Accept_Call) Run(run func()) *MockBrokerListener_Ac | |||
| 2040 | 3911 | return _c | |
| 2041 | 3912 | } | |
| 2042 | 3913 | ||
| 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) | |
| 2045 | 3916 | return _c | |
| 2046 | 3917 | } | |
| 2047 | 3918 | ||
| 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 { | |
| 2049 | 3920 | _c.Call.Return(run) | |
| 2050 | 3921 | return _c | |
| 2051 | 3922 | } | |
M internal/usecase/broker/pool.go +4 -4
| @@ -160,7 +160,7 @@ func (p *Pool) CloseStream(id ports.BrokerConnectionID, stream ports.BrokerStrea | |||
| 160 | 160 | return nil | |
| 161 | 161 | } | |
| 162 | 162 | ||
| 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) { | |
| 164 | 164 | if req.Epoch != p.epoch { | |
| 165 | 165 | return nil, ports.BrokerError{Code: ports.BrokerErrorStaleEpoch} | |
| 166 | 166 | } | |
| @@ -324,7 +324,7 @@ func (p *Pool) OpenStream(ctx context.Context, req ports.BrokerOpenStreamRequest | |||
| 324 | 324 | _ = raw.Close() | |
| 325 | 325 | return nil, terminal | |
| 326 | 326 | } | |
| 327 | - | stream := &pooledStream{BrokerLogicalConnection: raw, done: make(chan struct{}), release: release} | |
| 327 | + | stream := &pooledStream{BrokerEnvelopeStream: raw, done: make(chan struct{}), release: release} | |
| 328 | 328 | success = true | |
| 329 | 329 | go func() { | |
| 330 | 330 | var terminal error | |
| @@ -610,7 +610,7 @@ func (p *Pool) Close() error { | |||
| 610 | 610 | } | |
| 611 | 611 | ||
| 612 | 612 | type pooledStream struct { | |
| 613 | - | ports.BrokerLogicalConnection | |
| 613 | + | ports.BrokerEnvelopeStream | |
| 614 | 614 | once sync.Once | |
| 615 | 615 | done chan struct{} | |
| 616 | 616 | err error | |
| @@ -629,7 +629,7 @@ func (s *pooledStream) Err() error { | |||
| 629 | 629 | } | |
| 630 | 630 | func (s *pooledStream) Close() error { s.finish(nil); return s.closeErr } | |
| 631 | 631 | 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) }) | |
| 633 | 633 | } | |
| 634 | 634 | ||
| 635 | 635 | // 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) { | |||
| 28 | 28 | if stage == "connector" { | |
| 29 | 29 | return nil, tc.err | |
| 30 | 30 | } | |
| 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) { | |
| 32 | 32 | return nil, tc.err | |
| 33 | 33 | }}, nil | |
| 34 | 34 | }) | |
| @@ -52,7 +52,7 @@ func TestPoolRejectedPaths(t *testing.T) { | |||
| 52 | 52 | for _, name := range []string{"closed", "epoch", "invalid endpoint", "nil raw", "retiring"} { | |
| 53 | 53 | t.Run(name, func(t *testing.T) { | |
| 54 | 54 | 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) { | |
| 56 | 56 | return nil, nil | |
| 57 | 57 | }}, nil | |
| 58 | 58 | }) | |
| @@ -125,7 +125,7 @@ func TestPoolPostOpenPhysicalLoss(t *testing.T) { | |||
| 125 | 125 | raw := newFakeLogical() | |
| 126 | 126 | p, _ := setupPool(t, func(_ context.Context, e ports.BrokerDialTarget) (ports.BrokerPhysicalConnection, error) { | |
| 127 | 127 | 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) { | |
| 129 | 129 | _ = f.Close() | |
| 130 | 130 | return raw, nil | |
| 131 | 131 | } | |
| @@ -209,7 +209,7 @@ func (l *closeErrorLogical) Close() error { _ = l.fakeLogical.Close(); return l. | |||
| 209 | 209 | func TestPooledStreamPreservesCloseError(t *testing.T) { | |
| 210 | 210 | cause := errors.New("close failed") | |
| 211 | 211 | 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++ }} | |
| 213 | 213 | require.ErrorIs(t, s.Close(), cause) | |
| 214 | 214 | require.ErrorIs(t, s.Close(), cause) | |
| 215 | 215 | 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 | |||
| 36 | 36 | } | |
| 37 | 37 | ||
| 38 | 38 | type fakeLogical struct { | |
| 39 | - | ports.ClientConnection | |
| 40 | 39 | done chan struct{} | |
| 41 | 40 | once sync.Once | |
| 42 | 41 | } | |
| 43 | 42 | ||
| 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") } | |
| 49 | 49 | ||
| 50 | 50 | type fakePhysical struct { | |
| 51 | 51 | endpoint ports.BrokerDialTarget | |
| @@ -54,7 +54,7 @@ type fakePhysical struct { | |||
| 54 | 54 | identity ports.BrokerDaemonIdentity | |
| 55 | 55 | done chan struct{} | |
| 56 | 56 | once sync.Once | |
| 57 | - | open func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) | |
| 57 | + | open func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | 60 | func (f *fakePhysical) Identity() ports.BrokerDaemonIdentity { | |
| @@ -71,7 +71,7 @@ func (f *fakePhysical) FailureKind() domain.RemoteFailureKind { return domain.Re | |||
| 71 | 71 | func (f *fakePhysical) Done() <-chan struct{} { return f.done } | |
| 72 | 72 | func (f *fakePhysical) Err() error { return errors.New("physical loss") } | |
| 73 | 73 | 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) { | |
| 75 | 75 | if f.open != nil { | |
| 76 | 76 | return f.open(c, r) | |
| 77 | 77 | } | |
| @@ -140,7 +140,7 @@ func TestPoolOpenFailureWithTypedNilConnection(t *testing.T) { | |||
| 140 | 140 | return &fakePhysical{ | |
| 141 | 141 | endpoint: e, | |
| 142 | 142 | done: make(chan struct{}), | |
| 143 | - | open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) { | |
| 143 | + | open: func(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) { | |
| 144 | 144 | var absent *fakeLogical | |
| 145 | 145 | return absent, errors.New("open failed") | |
| 146 | 146 | }, | |
| @@ -164,7 +164,7 @@ func TestPoolHundredStreamsLossAndIsolation(t *testing.T) { | |||
| 164 | 164 | physical = &fakePhysical{endpoint: e, done: make(chan struct{})} | |
| 165 | 165 | return physical, nil | |
| 166 | 166 | }) | |
| 167 | - | streams := make([]ports.BrokerLogicalConnection, 100) | |
| 167 | + | streams := make([]ports.BrokerEnvelopeStream, 100) | |
| 168 | 168 | var wg sync.WaitGroup | |
| 169 | 169 | for i := range streams { | |
| 170 | 170 | id, err := p.RegisterClient() | |
| @@ -183,7 +183,7 @@ func TestPoolHundredStreamsLossAndIsolation(t *testing.T) { | |||
| 183 | 183 | wg.Wait() | |
| 184 | 184 | require.EqualValues(t, 1, calls.Load()) | |
| 185 | 185 | blocked := make(chan struct{}) | |
| 186 | - | go func() { _ = streams[0].SendClient(nil); close(blocked) }() | |
| 186 | + | go func() { _ = streams[0].SendEnvelope(nil); close(blocked) }() | |
| 187 | 187 | require.NoError(t, streams[0].Close()) | |
| 188 | 188 | await(t, blocked) | |
| 189 | 189 | select { | |
| @@ -336,7 +336,7 @@ func TestPoolCoalescedCancellation(t *testing.T) { | |||
| 336 | 336 | result := make(chan error, 1) | |
| 337 | 337 | go func() { _, err := p.OpenStream(ctx, poolRequest(id1, 1)); result <- err }() | |
| 338 | 338 | await(t, entered) | |
| 339 | - | result2 := make(chan ports.BrokerLogicalConnection, 1) | |
| 339 | + | result2 := make(chan ports.BrokerEnvelopeStream, 1) | |
| 340 | 340 | go func() { | |
| 341 | 341 | s, err := p.OpenStream(context.Background(), poolRequest(id2, 1)) | |
| 342 | 342 | if err != nil { | |
| @@ -475,7 +475,7 @@ func TestPoolAliasesAndPolicyPartition(t *testing.T) { | |||
| 475 | 475 | func TestPoolPendingOpenCancellationDoesNotHoldLock(t *testing.T) { | |
| 476 | 476 | entered := make(chan struct{}) | |
| 477 | 477 | 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) { | |
| 479 | 479 | if r.Stream == 1 { | |
| 480 | 480 | close(entered) | |
| 481 | 481 | <-ctx.Done() | |
M internal/usecase/broker/service.go +14 -11
| @@ -12,7 +12,7 @@ import ( | |||
| 12 | 12 | // Offline broker composition. | |
| 13 | 13 | // | |
| 14 | 14 | // 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 | |
| 16 | 16 | // connection. It is the structural implementation of ports.BrokerAuthority, | |
| 17 | 17 | // the admission seam the broker IPC listener (internal/adapters/brokeripc) | |
| 18 | 18 | // consumes and which this use case must not import: admission obtains one | |
| @@ -40,6 +40,7 @@ type Authority struct { | |||
| 40 | 40 | pool *Pool | |
| 41 | 41 | supervisor *Supervisor | |
| 42 | 42 | clock ports.Clock | |
| 43 | + | codec ports.SessionCodec | |
| 43 | 44 | } | |
| 44 | 45 | ||
| 45 | 46 | var _ ports.BrokerAuthority = (*Authority)(nil) | |
| @@ -53,7 +54,7 @@ var _ ports.BrokerAuthority = (*Authority)(nil) | |||
| 53 | 54 | // neither starts nor settles Run: serving connections without a live Run leaks | |
| 54 | 55 | // the writer and never flushes the newest staged publication, and a registry | |
| 55 | 56 | // 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) { | |
| 57 | 58 | if epoch == 0 || nilDependency(registry) || nilDependency(pool) || nilDependency(supervisor) { | |
| 58 | 59 | return nil, errors.New("broker: invalid authority dependencies") | |
| 59 | 60 | } | |
| @@ -64,10 +65,10 @@ func NewAuthority(epoch ports.BrokerEpoch, registry *Registry, pool *Pool, super | |||
| 64 | 65 | if len(clocks) > 0 { | |
| 65 | 66 | clk = clocks[0] | |
| 66 | 67 | } | |
| 67 | - | if nilDependency(clk) { | |
| 68 | + | if nilDependency(clk) || nilDependency(codec) { | |
| 68 | 69 | return nil, errors.New("broker: invalid authority clock") | |
| 69 | 70 | } | |
| 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 | |
| 71 | 72 | } | |
| 72 | 73 | ||
| 73 | 74 | // AdmitClient admits exactly one accepted client connection. The supervisor | |
| @@ -76,7 +77,7 @@ func NewAuthority(epoch ports.BrokerEpoch, registry *Registry, pool *Pool, super | |||
| 76 | 77 | // commits both or neither. ctx bounds admission only and is never retained: the | |
| 77 | 78 | // returned service derives its own connection-lived context from the supervisor | |
| 78 | 79 | // 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) { | |
| 80 | 81 | if err := ctx.Err(); err != nil { | |
| 81 | 82 | return nil, err | |
| 82 | 83 | } | |
| @@ -103,12 +104,12 @@ func (a *Authority) AdmitClient(ctx context.Context) (ports.BrokerService, error | |||
| 103 | 104 | } | |
| 104 | 105 | return newService(serviceConfig{ | |
| 105 | 106 | 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, | |
| 107 | 108 | }), nil | |
| 108 | 109 | } | |
| 109 | 110 | ||
| 110 | 111 | // 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. | |
| 112 | 113 | type Service struct { | |
| 113 | 114 | epoch ports.BrokerEpoch | |
| 114 | 115 | id ports.BrokerConnectionID | |
| @@ -118,6 +119,7 @@ type Service struct { | |||
| 118 | 119 | supervisor *Supervisor | |
| 119 | 120 | lease *Lease | |
| 120 | 121 | clock ports.Clock | |
| 122 | + | codec ports.SessionCodec | |
| 121 | 123 | ||
| 122 | 124 | // ctx owns everything this connection started: in-flight setup opens and | |
| 123 | 125 | // live streams. It is derived from the supervisor root, never from the | |
| @@ -154,7 +156,7 @@ type Service struct { | |||
| 154 | 156 | termErr error | |
| 155 | 157 | } | |
| 156 | 158 | ||
| 157 | - | var _ ports.BrokerService = (*Service)(nil) | |
| 159 | + | var _ ports.BrokerCoreService = (*Service)(nil) | |
| 158 | 160 | ||
| 159 | 161 | type serviceConfig struct { | |
| 160 | 162 | epoch ports.BrokerEpoch | |
| @@ -164,11 +166,12 @@ type serviceConfig struct { | |||
| 164 | 166 | supervisor *Supervisor | |
| 165 | 167 | lease *Lease | |
| 166 | 168 | clock ports.Clock | |
| 169 | + | codec ports.SessionCodec | |
| 167 | 170 | } | |
| 168 | 171 | ||
| 169 | 172 | func (c serviceConfig) validate() error { | |
| 170 | 173 | 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) { | |
| 172 | 175 | return errors.New("broker: invalid service dependencies") | |
| 173 | 176 | } | |
| 174 | 177 | return nil | |
| @@ -180,7 +183,7 @@ func newService(c serviceConfig) *Service { | |||
| 180 | 183 | } | |
| 181 | 184 | ctx, cancel := context.WithCancel(c.supervisor.RootContext()) | |
| 182 | 185 | 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, | |
| 184 | 187 | ctx: ctx, cancel: cancel, subs: make(map[*serviceSubscription]struct{}), | |
| 185 | 188 | done: make(chan struct{}), | |
| 186 | 189 | } | |
| @@ -284,7 +287,7 @@ func (s *Service) subscribe(demand bool) (ports.BrokerSubscription, error) { | |||
| 284 | 287 | // the pool sees it, and one operation lease pins the broker only while setup is | |
| 285 | 288 | // in flight: a stream that opens successfully outlives its setup lease, and | |
| 286 | 289 | // 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) { | |
| 288 | 291 | if err := s.scope(&request); err != nil { | |
| 289 | 292 | return nil, err | |
| 290 | 293 | } | |
M internal/usecase/broker/service_preview.go +4 -3
| @@ -199,7 +199,7 @@ func (p *servicePreviewSubscription) watch() (reopen, delivered bool) { | |||
| 199 | 199 | interval = previewLocalInterval | |
| 200 | 200 | } | |
| 201 | 201 | route, err := p.service.previewStreamRequest(p.request.Route) | |
| 202 | - | var stream ports.BrokerLogicalConnection | |
| 202 | + | var stream ports.BrokerEnvelopeStream | |
| 203 | 203 | if err == nil { | |
| 204 | 204 | stream, err = p.service.pool.OpenStream(p.ctx, route) | |
| 205 | 205 | } | |
| @@ -209,7 +209,8 @@ func (p *servicePreviewSubscription) watch() (reopen, delivered bool) { | |||
| 209 | 209 | defer func() { _ = stream.Close() }() | |
| 210 | 210 | stop := context.AfterFunc(p.ctx, func() { _ = stream.Close() }) | |
| 211 | 211 | 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 { | |
| 213 | 214 | return p.fail(err), false | |
| 214 | 215 | } | |
| 215 | 216 | ||
| @@ -232,7 +233,7 @@ func (p *servicePreviewSubscription) watch() (reopen, delivered bool) { | |||
| 232 | 233 | defer func() { markFirst(); <-deadlineDone }() | |
| 233 | 234 | ||
| 234 | 235 | for { | |
| 235 | - | message, err := stream.ReceiveServer() | |
| 236 | + | message, err := typed.ReceiveServer() | |
| 236 | 237 | if err != nil { | |
| 237 | 238 | return p.fail(err), delivered | |
| 238 | 239 | } | |
M internal/usecase/broker/service_preview_test.go +7 -4
| @@ -58,6 +58,8 @@ func (c *previewWatchConn) Capabilities() protocol.ConnectionCapabilities { | |||
| 58 | 58 | } | |
| 59 | 59 | func (c *previewWatchConn) LinkState() ports.LinkState { return ports.LinkStateConnected } | |
| 60 | 60 | 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") } | |
| 61 | 63 | func (c *previewWatchConn) Done() <-chan struct{} { return c.done } | |
| 62 | 64 | func (c *previewWatchConn) Err() error { return nil } | |
| 63 | 65 | func (c *previewWatchConn) Close() error { | |
| @@ -80,7 +82,7 @@ type previewTestConnector struct { | |||
| 80 | 82 | ||
| 81 | 83 | func (c *previewTestConnector) Connect(_ context.Context, e ports.BrokerDialTarget) (ports.BrokerPhysicalConnection, error) { | |
| 82 | 84 | 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) { | |
| 84 | 86 | conn := newPreviewWatchConn(r.Stream) | |
| 85 | 87 | c.opened <- conn | |
| 86 | 88 | return conn, nil | |
| @@ -96,7 +98,7 @@ func previewTarget(lifecycle byte, tab string) domain.RemoteSessionTarget { | |||
| 96 | 98 | } | |
| 97 | 99 | } | |
| 98 | 100 | ||
| 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 { | |
| 100 | 102 | return ports.BrokerPreviewRequest{ | |
| 101 | 103 | Epoch: 1, Connection: service.ConnectionID(), Generation: generation, | |
| 102 | 104 | Route: ports.BrokerPreviewRoute{Local: true, Policy: poolPolicy()}, | |
| @@ -110,7 +112,7 @@ func previewAnswer(lifecycle byte, tab string, width, height int) protocol.Remot | |||
| 110 | 112 | ||
| 111 | 113 | type previewFixture struct { | |
| 112 | 114 | t *testing.T | |
| 113 | - | service ports.BrokerService | |
| 115 | + | service ports.BrokerCoreService | |
| 114 | 116 | sub ports.BrokerPreviewSubscription | |
| 115 | 117 | connector *previewTestConnector | |
| 116 | 118 | clock *manualClock | |
| @@ -125,6 +127,7 @@ func newPreviewFixture(t *testing.T, target domain.RemoteSessionTarget) *preview | |||
| 125 | 127 | registry, err := NewRegistryWithConfig(1, newTestStore(), nil, clock, nil, RegistryConfig{ObservationDisabled: true}) | |
| 126 | 128 | require.NoError(t, err) | |
| 127 | 129 | authority, _, _, _ := composeTestAuthority(t, 1, registry, connector.Connect, clock) | |
| 130 | + | authority.codec = testSessionCodec{} | |
| 128 | 131 | service, err := authority.AdmitClient(context.Background()) | |
| 129 | 132 | require.NoError(t, err) | |
| 130 | 133 | t.Cleanup(func() { require.NoError(t, service.Close()) }) | |
| @@ -197,7 +200,7 @@ func TestServicePreviewStreamIDsDoNotConsumeClientIDs(t *testing.T) { | |||
| 197 | 200 | id, err := service.NextStreamID() | |
| 198 | 201 | require.NoError(t, err) | |
| 199 | 202 | 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))) | |
| 201 | 204 | require.NoError(t, err) | |
| 202 | 205 | t.Cleanup(func() { require.NoError(t, stream.Close()) }) | |
| 203 | 206 | } | |
M internal/usecase/broker/service_test.go +33 -22
| @@ -43,7 +43,7 @@ func composeTestAuthority(t testing.TB, epoch ports.BrokerEpoch, registry *Regis | |||
| 43 | 43 | require.NoError(t, err) | |
| 44 | 44 | t.Cleanup(func() { require.NoError(t, pool.Close()) }) | |
| 45 | 45 | supervisor, idleClock := newTestSupervisor(t, time.Hour) | |
| 46 | - | authority, err := NewAuthority(epoch, registry, pool, supervisor) | |
| 46 | + | authority, err := NewAuthority(epoch, registry, pool, supervisor, testSessionCodec{}) | |
| 47 | 47 | require.NoError(t, err) | |
| 48 | 48 | // The caller owns Registry.Run (see NewAuthority): start the single run and | |
| 49 | 49 | // cancel it at cleanup, so the registry's durable writer is drained and its | |
| @@ -195,7 +195,7 @@ func TestAuthorityAdmissionContextNotRetained(t *testing.T) { | |||
| 195 | 195 | require.NoError(t, registry.setHosts(hostRecords(registration(t, "user@host:22", 1)))) | |
| 196 | 196 | require.Len(t, service.Snapshot().Daemons, 1) | |
| 197 | 197 | ||
| 198 | - | stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 198 | + | stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 199 | 199 | require.NoError(t, err) | |
| 200 | 200 | require.NoError(t, stream.Close()) | |
| 201 | 201 | } | |
| @@ -210,7 +210,7 @@ func TestAuthorityValidation(t *testing.T) { | |||
| 210 | 210 | require.NoError(t, err) | |
| 211 | 211 | t.Cleanup(mutableRemote.settle) | |
| 212 | 212 | 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{}) | |
| 214 | 214 | require.NoError(t, err, "a mutable remote registry must be served") | |
| 215 | 215 | ||
| 216 | 216 | // A local-only observer is served: its entry is configured authority rather | |
| @@ -223,7 +223,7 @@ func TestAuthorityValidation(t *testing.T) { | |||
| 223 | 223 | }}) | |
| 224 | 224 | require.NoError(t, err) | |
| 225 | 225 | t.Cleanup(localOnly.settle) | |
| 226 | - | _, err = NewAuthority(1, localOnly, pool, supervisor) | |
| 226 | + | _, err = NewAuthority(1, localOnly, pool, supervisor, testSessionCodec{}) | |
| 227 | 227 | require.NoError(t, err, "a local-only observer must be served") | |
| 228 | 228 | ||
| 229 | 229 | // Construction still rejects remote observation without a probe: a registry | |
| @@ -235,17 +235,17 @@ func TestAuthorityValidation(t *testing.T) { | |||
| 235 | 235 | disabled, err := NewRegistryWithConfig(1, newTestStore(), nil, clock, nil, RegistryConfig{ObservationDisabled: true}) | |
| 236 | 236 | require.NoError(t, err) | |
| 237 | 237 | t.Cleanup(disabled.settle) | |
| 238 | - | _, err = NewAuthority(2, disabled, pool, supervisor) | |
| 238 | + | _, err = NewAuthority(2, disabled, pool, supervisor, testSessionCodec{}) | |
| 239 | 239 | require.Error(t, err, "an epoch mismatch must be refused") | |
| 240 | 240 | ||
| 241 | - | _, err = NewAuthority(1, nil, pool, supervisor) | |
| 241 | + | _, err = NewAuthority(1, nil, pool, supervisor, testSessionCodec{}) | |
| 242 | 242 | 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{}) | |
| 244 | 244 | 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{}) | |
| 246 | 246 | require.Error(t, err, "a missing supervisor must be refused") | |
| 247 | 247 | ||
| 248 | - | _, err = NewAuthority(1, disabled, pool, supervisor) | |
| 248 | + | _, err = NewAuthority(1, disabled, pool, supervisor, testSessionCodec{}) | |
| 249 | 249 | require.NoError(t, err) | |
| 250 | 250 | } | |
| 251 | 251 | ||
| @@ -289,7 +289,7 @@ func TestServiceOpenStreamScopeFencing(t *testing.T) { | |||
| 289 | 289 | require.NoError(t, err) | |
| 290 | 290 | t.Cleanup(func() { require.NoError(t, service.Close()) }) | |
| 291 | 291 | ||
| 292 | - | stream, err := service.OpenStream(context.Background(), tc.build(service.ConnectionID())) | |
| 292 | + | stream, err := service.OpenEnvelopeStream(context.Background(), tc.build(service.ConnectionID())) | |
| 293 | 293 | switch { | |
| 294 | 294 | case tc.wantStale: | |
| 295 | 295 | require.ErrorIs(t, err, ports.BrokerAdmissionStale) | |
| @@ -344,7 +344,7 @@ func TestServiceOpenStreamRequestsLocalReprobeOnOpenAndClose(t *testing.T) { | |||
| 344 | 344 | waitLocal(t, registry, func(o ports.BrokerDaemonObservation) bool { return !o.Checking }) | |
| 345 | 345 | ||
| 346 | 346 | // 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)) | |
| 348 | 348 | require.NoError(t, err) | |
| 349 | 349 | opened := receiveLocalCall(t, local) | |
| 350 | 350 | opened.result <- reachable() | |
| @@ -421,11 +421,11 @@ func TestServiceNextStreamIDAllocation(t *testing.T) { | |||
| 421 | 421 | require.NoError(t, err) | |
| 422 | 422 | request := poolRequest(service.ConnectionID(), 0) | |
| 423 | 423 | request.Stream = stream | |
| 424 | - | opened, err := service.OpenStream(context.Background(), request) | |
| 424 | + | opened, err := service.OpenEnvelopeStream(context.Background(), request) | |
| 425 | 425 | require.NoError(t, err) | |
| 426 | 426 | require.NoError(t, opened.Close()) | |
| 427 | 427 | // Replaying the exact identity is refused as stale. | |
| 428 | - | _, err = service.OpenStream(context.Background(), request) | |
| 428 | + | _, err = service.OpenEnvelopeStream(context.Background(), request) | |
| 429 | 429 | require.ErrorIs(t, err, ports.BrokerAdmissionStale) | |
| 430 | 430 | }) | |
| 431 | 431 | } | |
| @@ -448,7 +448,7 @@ func TestServiceOpenStreamAdmissionValidatesCallerInput(t *testing.T) { | |||
| 448 | 448 | t.Run(tc.name, func(t *testing.T) { | |
| 449 | 449 | request := poolRequest(service.ConnectionID(), 1) | |
| 450 | 450 | tc.mutate(&request) | |
| 451 | - | _, err := service.OpenStream(context.Background(), request) | |
| 451 | + | _, err := service.OpenEnvelopeStream(context.Background(), request) | |
| 452 | 452 | require.ErrorIs(t, err, ports.BrokerAdmissionInvalid) | |
| 453 | 453 | }) | |
| 454 | 454 | } | |
| @@ -461,7 +461,7 @@ func TestServiceCloseStreamScopeFencing(t *testing.T) { | |||
| 461 | 461 | t.Cleanup(func() { require.NoError(t, service.Close()) }) | |
| 462 | 462 | id := service.ConnectionID() | |
| 463 | 463 | ||
| 464 | - | stream, err := service.OpenStream(context.Background(), poolRequest(id, 1)) | |
| 464 | + | stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(id, 1)) | |
| 465 | 465 | require.NoError(t, err) | |
| 466 | 466 | ||
| 467 | 467 | // A wrong-scope close must not retire this connection's stream. | |
| @@ -610,12 +610,12 @@ func TestServiceOperationLeaseLifetime(t *testing.T) { | |||
| 610 | 610 | t.Cleanup(func() { require.NoError(t, service.Close()) }) | |
| 611 | 611 | ||
| 612 | 612 | type opened struct { | |
| 613 | - | stream ports.BrokerLogicalConnection | |
| 613 | + | stream ports.BrokerEnvelopeStream | |
| 614 | 614 | err error | |
| 615 | 615 | } | |
| 616 | 616 | result := make(chan opened, 1) | |
| 617 | 617 | go func() { | |
| 618 | - | stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 618 | + | stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 619 | 619 | result <- opened{stream: stream, err: err} | |
| 620 | 620 | }() | |
| 621 | 621 | <-entered | |
| @@ -656,7 +656,7 @@ func TestServiceCloseOpenRace(t *testing.T) { | |||
| 656 | 656 | ||
| 657 | 657 | result := make(chan error, 1) | |
| 658 | 658 | go func() { | |
| 659 | - | _, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 659 | + | _, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 660 | 660 | result <- err | |
| 661 | 661 | }() | |
| 662 | 662 | <-entered | |
| @@ -683,7 +683,7 @@ func TestServiceCloseIsIdempotentAndConcurrent(t *testing.T) { | |||
| 683 | 683 | require.NoError(t, err) | |
| 684 | 684 | _, err = service.Subscribe() | |
| 685 | 685 | 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)) | |
| 687 | 687 | require.NoError(t, err) | |
| 688 | 688 | ||
| 689 | 689 | const closers = 8 | |
| @@ -708,7 +708,7 @@ func TestServiceCloseIsIdempotentAndConcurrent(t *testing.T) { | |||
| 708 | 708 | require.Zero(t, clients) | |
| 709 | 709 | await(t, stream.Done()) | |
| 710 | 710 | ||
| 711 | - | _, err = service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 2)) | |
| 711 | + | _, err = service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 2)) | |
| 712 | 712 | requireBrokerClosed(t, err) | |
| 713 | 713 | } | |
| 714 | 714 | ||
| @@ -747,7 +747,7 @@ func TestServiceShutdownTerminatesOwnedWork(t *testing.T) { | |||
| 747 | 747 | service, err := authority.AdmitClient(context.Background()) | |
| 748 | 748 | require.NoError(t, err) | |
| 749 | 749 | ||
| 750 | - | stream, err := service.OpenStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 750 | + | stream, err := service.OpenEnvelopeStream(context.Background(), poolRequest(service.ConnectionID(), 1)) | |
| 751 | 751 | require.NoError(t, err) | |
| 752 | 752 | ||
| 753 | 753 | // Broker shutdown cancels the connection root: owned streams end even before | |
| @@ -1156,7 +1156,7 @@ func TestRegistryObservationDisabledDrainsWriter(t *testing.T) { | |||
| 1156 | 1156 | } | |
| 1157 | 1157 | ||
| 1158 | 1158 | 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{}} | |
| 1160 | 1160 | tests := []struct { | |
| 1161 | 1161 | name string | |
| 1162 | 1162 | mutate func(*serviceConfig) | |
| @@ -1170,6 +1170,7 @@ func TestServiceConfigValidation(t *testing.T) { | |||
| 1170 | 1170 | {"nil supervisor", func(c *serviceConfig) { c.supervisor = nil }}, | |
| 1171 | 1171 | {"nil lease", func(c *serviceConfig) { c.lease = nil }}, | |
| 1172 | 1172 | {"nil clock", func(c *serviceConfig) { c.clock = nil }}, | |
| 1173 | + | {"nil codec", func(c *serviceConfig) { c.codec = nil }}, | |
| 1173 | 1174 | } | |
| 1174 | 1175 | require.NoError(t, valid.validate()) | |
| 1175 | 1176 | for _, tt := range tests { | |
| @@ -1180,3 +1181,13 @@ func TestServiceConfigValidation(t *testing.T) { | |||
| 1180 | 1181 | }) | |
| 1181 | 1182 | } | |
| 1182 | 1183 | } | |
| 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 | |||
| 65 | 65 | return nil, errors.New("integration core does not support preview") | |
| 66 | 66 | } | |
| 67 | 67 | ||
| 68 | - | func (c *integrationCore) OpenStream(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerLogicalConnection, error) { | |
| 68 | + | func (c *integrationCore) OpenEnvelopeStream(context.Context, ports.BrokerOpenStreamRequest) (ports.BrokerEnvelopeStream, error) { | |
| 69 | 69 | return nil, errors.New("integration core does not support streams") | |
| 70 | 70 | } | |
| 71 | 71 | ||
| @@ -110,7 +110,7 @@ type integrationAuthority struct { | |||
| 110 | 110 | ||
| 111 | 111 | var _ ports.BrokerAuthority = (*integrationAuthority)(nil) | |
| 112 | 112 | ||
| 113 | - | func (a *integrationAuthority) AdmitClient(ctx context.Context) (ports.BrokerService, error) { | |
| 113 | + | func (a *integrationAuthority) AdmitClient(ctx context.Context) (ports.BrokerCoreService, error) { | |
| 114 | 114 | if err := ctx.Err(); err != nil { | |
| 115 | 115 | return nil, err | |
| 116 | 116 | } | |