Skip to content

Commit

Permalink
Update configurations
Browse files Browse the repository at this point in the history
Remove the in-region and low-latency configurations and replace them
with a browser configuration.

Split the deadline and metadata creation into separate functions.
  • Loading branch information
nand4011 committed May 19, 2023
1 parent 2c29bae commit 8944650
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 112 deletions.
80 changes: 12 additions & 68 deletions packages/client-sdk-web/src/config/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const defaultLoggerFactory: MomentoLoggerFactory =
new DefaultMomentoLoggerFactory();

/**
* Laptop config provides defaults suitable for a medium-to-high-latency dev environment. Permissive timeouts, retries, and
* relaxed latency and throughput targets.
* Laptop config provides defaults suitable for a medium-to-high-latency dev environment.
* @export
* @class Laptop
*/
Expand Down Expand Up @@ -55,98 +54,43 @@ export class Laptop extends CacheConfiguration {
}
}

class InRegionDefault extends CacheConfiguration {
/**
* Browser config provides defaults suitable for use in a web browser.
* @export
* @class Browser
*/
export class Browser extends CacheConfiguration {
/**
* Provides the latest recommended configuration for a typical in-region environment. NOTE: this configuration may
* Provides the latest recommended configuration for an in-browser environment. NOTE: this configuration may
* change in future releases to take advantage of improvements we identify for default configurations.
* @param {MomentoLoggerFactory} [loggerFactory=defaultLoggerFactory]
* @returns {CacheConfiguration}
*/
static latest(
loggerFactory: MomentoLoggerFactory = defaultLoggerFactory
): CacheConfiguration {
return InRegionDefault.v1(loggerFactory);
return Browser.v1(loggerFactory);
}

/**
* Provides v1 recommended configuration for a typical in-region environment. This configuration is guaranteed not
* Provides v1 recommended configuration for an in-browser environment. This configuration is guaranteed not
* to change in future releases of the Momento node.js SDK.
* @param {MomentoLoggerFactory} [loggerFactory=defaultLoggerFactory]
* @returns {CacheConfiguration}
*/
static v1(
loggerFactory: MomentoLoggerFactory = defaultLoggerFactory
): CacheConfiguration {
const deadlineMillis = 1100;
const grpcConfig: GrpcConfiguration = new StaticGrpcConfiguration({
deadlineMillis: deadlineMillis,
});
const transportStrategy: TransportStrategy = new StaticTransportStrategy({
grpcConfiguration: grpcConfig,
});
return new InRegionDefault({
loggerFactory: loggerFactory,
transportStrategy: transportStrategy,
});
}
}

class InRegionLowLatency extends CacheConfiguration {
/**
* Provides the latest recommended configuration for an in-region environment with aggressive low-latency requirements.
* NOTE: this configuration may change in future releases to take advantage of improvements we identify for default
* configurations.
* @param {MomentoLoggerFactory} [loggerFactory=defaultLoggerFactory]
* @returns {CacheConfiguration}
*/
static latest(
loggerFactory: MomentoLoggerFactory = defaultLoggerFactory
): CacheConfiguration {
return InRegionLowLatency.v1(loggerFactory);
}

/**
* Provides v1 recommended configuration for an in-region environment with aggressive low-latency requirements.
* This configuration is guaranteed not to change in future releases of the Momento node.js SDK.
* @param {MomentoLoggerFactory} [loggerFactory=defaultLoggerFactory]
* @returns {CacheConfiguration}
*/
static v1(
loggerFactory: MomentoLoggerFactory = defaultLoggerFactory
): CacheConfiguration {
const deadlineMillis = 500;
const deadlineMillis = 5000;
const grpcConfig: GrpcConfiguration = new StaticGrpcConfiguration({
deadlineMillis: deadlineMillis,
});
const transportStrategy: TransportStrategy = new StaticTransportStrategy({
grpcConfiguration: grpcConfig,
});
return new InRegionDefault({
return new Browser({
loggerFactory: loggerFactory,
transportStrategy: transportStrategy,
});
}
}

/**
* InRegion provides defaults suitable for an environment where your client is running in the same region as the Momento
* service. It has more aggressive timeouts and retry behavior than the Laptop config.
* @export
* @class InRegion
*/
export class InRegion {
/**
* This config prioritizes throughput and client resource utilization. It has a slightly relaxed client-side timeout
* setting to maximize throughput.
* @type {InRegionDefault}
*/
static Default = InRegionDefault;
/**
* This config prioritizes keeping p99.9 latencies as low as possible, potentially sacrificing
* some throughput to achieve this. It has a very aggressive client-side timeout. Use this
* configuration if the most important factor is to ensure that cache unavailability doesn't force
* unacceptably high latencies for your own application.
* @type {InRegionLowLatency}
*/
static LowLatency = InRegionLowLatency;
}
Loading

0 comments on commit 8944650

Please sign in to comment.