55 "errors"
66 "net/url"
77
8+ "github.com/exanubes/appsync/authorizer"
89 "github.com/exanubes/appsync/internal/app"
910 "github.com/exanubes/appsync/internal/app/engine"
1011 "github.com/exanubes/appsync/internal/app/heartbeat"
@@ -14,8 +15,8 @@ import (
1415 "github.com/exanubes/appsync/internal/app/runtime"
1516 "github.com/exanubes/appsync/internal/app/services/connection"
1617 "github.com/exanubes/appsync/internal/app/services/io"
18+ "github.com/exanubes/appsync/internal/app/usecases/shutdown"
1719 "github.com/exanubes/appsync/internal/composition"
18- "github.com/exanubes/appsync/authorizer"
1920 infra_authorizer "github.com/exanubes/appsync/internal/infrastructure/authorizer"
2021 "github.com/exanubes/appsync/internal/infrastructure/clock"
2122 "github.com/exanubes/appsync/internal/infrastructure/codec"
@@ -138,24 +139,32 @@ func (builder *builder) Connect(ctx context.Context) (*appsync_client, error) {
138139 egress_queue := queue .NewEgressQueue (builder .backpressure .ConnectionOutbound )
139140 pending_registry := pending .NewRegistry ()
140141 io_loops := io .New (ingress_queue , egress_queue , connection_output .Connection , msg_codec )
141- usecases := composition .NewUseCases (
142+ usecases , services := composition .NewUseCases (
142143 request_authorizer ,
143144 ingress_queue ,
144145 egress_queue ,
145146 pending_registry ,
146147 builder .backpressure .SubscriptionEvents ,
147148 )
149+
148150 msg_router := router .New (pending_registry , usecases .ReceiveData )
149151 runtime := runtime .New (ingress_queue , msg_router , heartbeat )
150152 session := engine .New (heartbeat , runtime , io_loops , builder .logger )
151153 session .Start (ctx , engine.StartEngineInput {
152154 Timeout : connection_output .Timeout ,
153155 })
154156
157+ shutdown_connection_usecase := shutdown .NewShutdownConnectionUsecase (
158+ services .SubscriptionsRegistry ,
159+ services .RemoveSubscriptions ,
160+ session ,
161+ connection_output .Connection ,
162+ )
163+
164+ usecases .Shutdown = shutdown_connection_usecase
165+
155166 return & appsync_client {
156- transport : connection_output .Connection ,
157- runtime : session ,
158- usecases : usecases ,
167+ usecases : usecases ,
159168 }, nil
160169}
161170
0 commit comments