|
1 | 1 | import { Schema } from "@effect/schema"; |
2 | 2 | import { |
| 3 | + type ChannelCredentials, |
| 4 | + type ChannelOptions, |
3 | 5 | type DefaultCallOptions, |
4 | 6 | type NormalizedServiceDefinition, |
5 | 7 | createChannel, |
@@ -44,20 +46,32 @@ export interface Client<TFilter, TBlock> { |
44 | 46 | ): AsyncIterable<StreamDataResponse<TBlock>>; |
45 | 47 | } |
46 | 48 |
|
| 49 | +export type CreateClientOptions = { |
| 50 | + defaultCallOptions?: DefaultCallOptions< |
| 51 | + NormalizedServiceDefinition<proto.stream.DnaStreamDefinition> |
| 52 | + >; |
| 53 | + credentials?: ChannelCredentials; |
| 54 | + channelOptions?: ChannelOptions; |
| 55 | +}; |
| 56 | + |
47 | 57 | /** Create a client connecting to the DNA grpc service. */ |
48 | 58 | export function createClient<TFilter, TBlock>( |
49 | 59 | config: StreamConfig<TFilter, TBlock>, |
50 | 60 | streamUrl: string, |
51 | | - defaultCallOptions?: DefaultCallOptions< |
52 | | - NormalizedServiceDefinition<proto.stream.DnaStreamDefinition> |
53 | | - >, |
| 61 | + options: CreateClientOptions = {}, |
54 | 62 | ) { |
55 | | - const channel = createChannel(streamUrl); |
| 63 | + const channel = createChannel( |
| 64 | + streamUrl, |
| 65 | + options?.credentials, |
| 66 | + options?.channelOptions, |
| 67 | + ); |
| 68 | + |
56 | 69 | const client: proto.stream.DnaStreamClient = grpcCreateClient( |
57 | 70 | proto.stream.DnaStreamDefinition, |
58 | 71 | channel, |
59 | | - defaultCallOptions, |
| 72 | + options?.defaultCallOptions, |
60 | 73 | ); |
| 74 | + |
61 | 75 | return new GrpcClient(config, client); |
62 | 76 | } |
63 | 77 |
|
|
0 commit comments