1.0.0 • Published 9 months ago

@effect-aws/client-cloudwatch v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

@effect-aws/client-cloudwatch

npm version npm downloads

Installation

npm install --save @effect-aws/client-cloudwatch

Usage

With default CloudWatchClient instance:

import { CloudWatchService, DefaultCloudWatchServiceLayer } from "@effect-aws/client-cloudwatch";

const program = CloudWatchService.describeAlarms(args);

const result = pipe(
  program,
  Effect.provide(DefaultCloudWatchServiceLayer),
  Effect.runPromise,
);

With custom CloudWatchClient instance:

import {
  CloudWatchService,
  BaseCloudWatchServiceLayer,
  CloudWatchClientInstance,
} from "@effect-aws/client-cloudwatch";

const program = CloudWatchService.describeAlarms(args);

const CloudWatchClientInstanceLayer = Layer.succeed(
  CloudWatchClientInstance,
  new CloudWatchClient({ region: "eu-central-1" }),
);

const result = await pipe(
  program,
  Effect.provide(BaseCloudWatchServiceLayer),
  Effect.provide(CloudWatchClientInstanceLayer),
  Effect.runPromise,
);

With custom CloudWatchClient configuration:

import {
  CloudWatchService,
  BaseCloudWatchServiceLayer,
  DefaultCloudWatchClientConfigLayer,
  CloudWatchClientInstance,
  CloudWatchClientInstanceConfig,
} from "@effect-aws/client-cloudwatch";

const program = CloudWatchService.describeAlarms(args);

const CloudWatchClientInstanceLayer = Layer.provide(
  Layer.effect(
    CloudWatchClientInstance,
    CloudWatchClientInstanceConfig.pipe(
      Effect.map(
        (config) => new CloudWatchClient({ ...config, region: "eu-central-1" }),
      ),
    ),
  ),
  DefaultCloudWatchClientConfigLayer,
);

const result = await pipe(
  program,
  Effect.provide(BaseCloudWatchServiceLayer),
  Effect.provide(CloudWatchClientInstanceLayer),
  Effect.runPromiseExit,
);

or map over DefaultCloudWatchClientConfigLayer layer context and update the configuration...

1.0.0

9 months ago