-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
252 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/client-sdk-nodejs/src/config/leaderboard-configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
packages/client-sdk-nodejs/src/config/transport/topics/grpc-configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export interface TopicGrpcConfigurationProps { | ||
/** | ||
* The number of internal clients a cache client will create to communicate with Momento. More of them allows | ||
* more concurrent requests, at the cost of more open connections and the latency of setting up each client. | ||
*/ | ||
numClients?: number; | ||
} | ||
|
||
/** | ||
* Encapsulates gRPC configuration tunables. | ||
* @export | ||
* @interface TopicGrpcConfiguration | ||
*/ | ||
export interface TopicGrpcConfiguration { | ||
/** | ||
* @returns {number} the number of internal clients a cache client will create to communicate with Momento. More of | ||
* them will allow for more concurrent requests. | ||
*/ | ||
getNumClients(): number; | ||
|
||
/** | ||
* Copy constructor for overriding the number of clients to create | ||
* @param {number} numClients the number of internal clients to create | ||
* @returns {GrpcConfiguration} a new GrpcConfiguration with the specified number of clients | ||
*/ | ||
withNumClients(numClients: number): TopicGrpcConfiguration; | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/client-sdk-nodejs/src/config/transport/topics/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './grpc-configuration'; | ||
export * from './transport-strategy'; |
69 changes: 69 additions & 0 deletions
69
packages/client-sdk-nodejs/src/config/transport/topics/transport-strategy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
TopicGrpcConfiguration, | ||
TopicGrpcConfigurationProps, | ||
} from './grpc-configuration'; | ||
|
||
export interface TopicTransportStrategy { | ||
/** | ||
* Configures the low-level gRPC settings for the Momento client's communication | ||
* with the Momento server. | ||
* @returns {TopicGrpcConfiguration} | ||
*/ | ||
getGrpcConfig(): TopicGrpcConfiguration; | ||
|
||
/** | ||
* Copy constructor for overriding the gRPC configuration | ||
* @param {TopicGrpcConfiguration} grpcConfig | ||
* @returns {TopicTransportStrategy} a new TransportStrategy with the specified gRPC config. | ||
*/ | ||
withGrpcConfig(grpcConfig: TopicGrpcConfiguration): TopicTransportStrategy; | ||
} | ||
|
||
export interface TopicTransportStrategyProps { | ||
/** | ||
* low-level gRPC settings for communication with the Momento server | ||
*/ | ||
grpcConfiguration: TopicGrpcConfiguration; | ||
} | ||
|
||
export class StaticTopicGrpcConfiguration implements TopicGrpcConfiguration { | ||
private readonly numClients: number; | ||
|
||
constructor(props: TopicGrpcConfigurationProps) { | ||
if (props.numClients !== undefined && props.numClients !== null) { | ||
this.numClients = props.numClients; | ||
} else { | ||
this.numClients = 1; | ||
} | ||
} | ||
|
||
getNumClients(): number { | ||
return this.numClients; | ||
} | ||
|
||
withNumClients(numClients: number): TopicGrpcConfiguration { | ||
return new StaticTopicGrpcConfiguration({ | ||
numClients: numClients, | ||
}); | ||
} | ||
} | ||
|
||
export class StaticTopicTransportStrategy implements TopicTransportStrategy { | ||
private readonly grpcConfig: TopicGrpcConfiguration; | ||
|
||
constructor(props: TopicTransportStrategyProps) { | ||
this.grpcConfig = props.grpcConfiguration; | ||
} | ||
|
||
getGrpcConfig(): TopicGrpcConfiguration { | ||
return this.grpcConfig; | ||
} | ||
|
||
withGrpcConfig( | ||
grpcConfig: TopicGrpcConfiguration | ||
): StaticTopicTransportStrategy { | ||
return new StaticTopicTransportStrategy({ | ||
grpcConfiguration: grpcConfig, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/client-sdk-nodejs/src/internal/grpc/grpc-channel-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
packages/client-sdk-nodejs/test/unit/config/configuration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.