@@ -46,9 +46,8 @@ import {
46
46
} from "./types" ;
47
47
import { FumaroleSM } from "./runtime/state-machine" ;
48
48
import { downloadSlotObserverFactory , GrpcSlotDownloader } from "./runtime/grpc-slot-downloader" ;
49
- import { DownloadTaskArgs , DownloadTaskResult , FumeDragonsmouthRuntime , RuntimeEvent } from "./runtime/runtime" ;
49
+ import { DownloadTaskArgs , DownloadTaskResult , fumaroleObservable , FumaroleRuntimeArgs , RuntimeEvent } from "./runtime/runtime" ;
50
50
import { firstValueFrom , from , Observable , Observer , share , Subject } from "rxjs" ;
51
- import { combineHostPort } from "@grpc/grpc-js/build/src/uri-parser" ;
52
51
import { createDeferred } from "./utils/promise" ;
53
52
54
53
( BigInt . prototype as any ) . toJSON = function ( ) {
@@ -146,32 +145,26 @@ export class FumaroleClient {
146
145
async dragonsmouthSubscribe (
147
146
consumerGroupName : string ,
148
147
request : SubscribeRequest ,
149
- xToken : string
150
- ) : Promise < void > {
148
+ ) : Promise < Observable < SubscribeUpdate > > {
151
149
return this . dragonsmouthSubscribeWithConfig (
152
150
consumerGroupName ,
153
151
request ,
154
152
getDefaultFumaroleSubscribeConfig ( ) ,
155
- xToken
156
153
) ;
157
154
}
158
155
159
156
public async dragonsmouthSubscribeWithConfig (
160
157
consumerGroupName : string ,
161
- request : SubscribeRequest ,
158
+ initialSubscribeRequest : SubscribeRequest ,
162
159
config : FumaroleSubscribeConfig ,
163
- xToken : string
164
- ) : Promise < void > {
160
+ ) : Promise < Observable < SubscribeUpdate > > {
165
161
166
162
const initialJoin : JoinControlPlane = { consumerGroupName } ;
167
163
const initialJoinCommand : ControlCommand = { initialJoin } ;
168
164
const controlPlaneCommandSubject = new Subject < ControlCommand > ( ) ;
169
165
const fumaroleRuntimeEventSubject = new Subject < RuntimeEvent > ( ) ;
170
166
171
167
const metadata = new Metadata ( ) ;
172
- // TODO remove the x-subscription-id
173
- metadata . add ( "x-subscription-id" , xToken ) ;
174
- metadata . add ( "x-token" , xToken ) ;
175
168
176
169
console . log ( "SUBSCRIBE METADATA" ) ;
177
170
console . log ( metadata . getMap ( ) ) ;
@@ -214,44 +207,32 @@ export class FumaroleClient {
214
207
const sm = new FumaroleSM ( lastCommittedOffset , config . slotMemoryRetention ) ;
215
208
216
209
const dragonsmouthOutlet = new Subject < SubscribeUpdate > ( ) ;
217
- const downloadTaskSubject = new Subject < DownloadTaskResult > ( ) ;
210
+ const downloadTaskResultSubject = new Subject < DownloadTaskResult > ( ) ;
218
211
// // Connect data plane and create slot downloader
219
212
const dataPlaneClient = await this . connector . connect ( ) ;
220
213
const grpcSlotDownloadCtx : GrpcSlotDownloader = {
221
214
client : dataPlaneClient ,
222
215
client_metadata : metadata ,
223
216
dragonsmouthOutlet : dragonsmouthOutlet ,
224
- downloadTaskResultObserver : downloadTaskSubject ,
217
+ downloadTaskResultObserver : downloadTaskResultSubject ,
225
218
}
226
219
const grpcSlotDownloader : Observer < DownloadTaskArgs > = downloadSlotObserverFactory (
227
220
grpcSlotDownloadCtx
228
221
)
229
-
230
222
231
223
232
- // Create Fume runtime
233
- // const rt = new FumeDragonsmouthRuntime(
234
- // sm,
235
- // grpcSlotDownloader,
236
- // subscribeRequestQueue,
237
- // request,
238
- // consumerGroupName,
239
- // fumeControlPlaneQ,
240
- // fumeControlPlaneRxQ,
241
- // dragonsmouthOutlet,
242
- // config.commitInterval,
243
- // config.gcInterval,
244
- // config.concurrentDownloadLimit
245
- // );
246
-
247
- // const fumaroleHandle = rt.run();
248
- // console.log(`Fumarole handle created:`, fumaroleHandle);
249
-
250
- // return {
251
- // sink: subscribeRequestQueue,
252
- // source: dragonsmouthOutlet,
253
- // fumaroleHandle,
254
- // };
224
+ const runtimeArgs : FumaroleRuntimeArgs = {
225
+ downloadTaskObserver : grpcSlotDownloader ,
226
+ downloadTaskResultObservable : downloadTaskResultSubject . asObservable ( ) ,
227
+ controlPlaneObserver : controlPlaneCommandSubject ,
228
+ controlPlaneResponseObservable : ctrlPlaneResponseObservable ,
229
+ sm,
230
+ commitIntervalMillis : config . commitInterval ,
231
+ maxConcurrentDownload : config . concurrentDownloadLimit ,
232
+ initialSubscribeRequest,
233
+ }
234
+
235
+ return fumaroleObservable ( runtimeArgs )
255
236
}
256
237
257
238
async listConsumerGroups ( ) : Promise < ListConsumerGroupsResponse > {
0 commit comments