diff --git a/package.json b/package.json index 49798f5d1..1d45fab6f 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "@effect/language-service": "^0.0.21", - "@effect/opentelemetry": "^0.26.0", + "@effect/opentelemetry": "^0.27.0", "@mdx-js/mdx": "^2.3.0", "@opentelemetry/exporter-trace-otlp-http": "0.43.0", "@opentelemetry/sdk-trace-base": "^1.17.1", @@ -34,7 +34,7 @@ "@typescript-eslint/eslint-plugin": "^6.7.4", "@typescript-eslint/parser": "^6.7.4", "autoprefixer": "^10.4.14", - "effect": "2.0.0-next.59", + "effect": "2.0.0-next.60", "eslint": "^8.38.0", "eslint-config-next": "^13.3.0", "eslint-config-prettier": "^8.8.0", diff --git a/pages/docs/configuration.mdx b/pages/docs/configuration.mdx index abf1b7e92..137875a7e 100644 --- a/pages/docs/configuration.mdx +++ b/pages/docs/configuration.mdx @@ -10,11 +10,11 @@ Effect comes bundled with a straightforward default `ConfigProvider` that retrie To make our application configurable, we need to understand three essential elements: -- **Config Description**: We describe the configuration data using an instance of `Config`. If the configuration data is simple, such as a `string`, `number`, or `boolean`, we can use the built-in functions provided by the `Config` module. For more complex data types like `HostPort`, we can combine primitive configs to create a custom configuration description. +- **Config Description**: We describe the configuration data using an instance of `Config`. If the configuration data is simple, such as a `string`, `number`, or `boolean`, we can use the built-in functions provided by the `Config` module. For more complex data types like [`HostPort`](#custom-configurations), we can combine primitive configs to create a custom configuration description. -- **Config Frontend**: We use `Effect.config` to load the configuration data described by a `Config` instance. This function leverages the current `ConfigProvider` to retrieve the configuration. +- **Config Frontend**: We utilize the instance of `Config` to load the configuration data described by the instance (a `Config` is, in itself, an effect). This process leverages the current `ConfigProvider` to retrieve the configuration. -- **Config Backend**: The `ConfigProvider` is the underlying engine that powers `Effect.config` and handles the loading of configurations. Effect comes with a default config provider as part of its default services. This default provider reads the configuration data from environment variables. If we want to use a custom config provider, we can utilize the `Effect.setConfigProvider` layer to configure the Effect runtime accordingly. +- **Config Backend**: The `ConfigProvider` serves as the underlying engine that manages the configuration loading process. Effect comes with a default config provider as part of its default services. This default provider reads the configuration data from environment variables. If we want to use a custom config provider, we can utilize the `Effect.setConfigProvider` layer to configure the Effect runtime accordingly. ## Primitives @@ -117,14 +117,14 @@ If we use this customized configuration in our application: -```ts filename="App.ts" /Effect.config(HostPort.config)/ file=/src/configuration/App-gen.ts +```ts filename="App.ts" /HostPort.config/ file=/src/configuration/App-gen.ts ``` -```ts filename="App.ts" /Effect.config(HostPort.config)/ file=/src/configuration/App.ts +```ts filename="App.ts" /HostPort.config/ file=/src/configuration/App.ts ``` diff --git a/pages/docs/observability/logging.mdx b/pages/docs/observability/logging.mdx index 2d46b5520..ed6011164 100644 --- a/pages/docs/observability/logging.mdx +++ b/pages/docs/observability/logging.mdx @@ -32,7 +32,7 @@ The log message contains the following information: - `timestamp`: The timestamp when the log message was generated. - `level`: The log level at which the message is logged. -- `fiber`: The identifier of the [fiber](../concurrency/fibers#what-is-a-fiber) executing the program. +- `fiber`: The identifier of the [fiber](../concurrency/fibers.mdx#what-is-a-fiber) executing the program. - `message`: The content of the log message. - `span`: (Optional) The duration of the span in milliseconds. @@ -210,13 +210,13 @@ In this approach, you create a custom runtime that incorporates the configuratio ## Loading the Log Level from Configuration -To retrieve the log level from a [configuration](../configuration) and incorporate it into your program, utilize the layer produced by `Logger.minimumLogLevel`: +To retrieve the log level from a [configuration](../configuration.mdx) and incorporate it into your program, utilize the layer produced by `Logger.minimumLogLevel`: ```ts file=/src/logging/load-log-level-from-configuration.ts ``` -To evaluate the configured program, you can utilize `ConfigProvider.fromMap` for testing (refer to [Testing Services](../configuration#testing-services) for more details). +To evaluate the configured program, you can utilize `ConfigProvider.fromMap` for testing (refer to [Testing Services](../configuration.mdx#testing-services) for more details). ## Custom loggers diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 568cd1857..8848411cb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,8 +29,8 @@ devDependencies: specifier: ^0.0.21 version: 0.0.21 '@effect/opentelemetry': - specifier: ^0.26.0 - version: 0.26.0(@opentelemetry/api@1.6.0)(@opentelemetry/resources@1.17.1)(@opentelemetry/sdk-trace-base@1.17.1)(@opentelemetry/semantic-conventions@1.17.1)(effect@2.0.0-next.59) + specifier: ^0.27.0 + version: 0.27.0(@opentelemetry/api@1.6.0)(@opentelemetry/resources@1.17.1)(@opentelemetry/sdk-trace-base@1.17.1)(@opentelemetry/semantic-conventions@1.17.1)(effect@2.0.0-next.60) '@mdx-js/mdx': specifier: ^2.3.0 version: 2.3.0 @@ -62,8 +62,8 @@ devDependencies: specifier: ^10.4.14 version: 10.4.14(postcss@8.4.23) effect: - specifier: 2.0.0-next.59 - version: 2.0.0-next.59 + specifier: 2.0.0-next.60 + version: 2.0.0-next.60 eslint: specifier: ^8.38.0 version: 8.39.0 @@ -162,8 +162,8 @@ packages: resolution: {integrity: sha512-e8vfKbjnbYiyneBincEFS0tzXluopGK77OkVFbPRtUbNDS5tJfb+jiwOQEiqASDsadcZmd+9J9+Q6v/z7GuN2g==} dev: true - /@effect/opentelemetry@0.26.0(@opentelemetry/api@1.6.0)(@opentelemetry/resources@1.17.1)(@opentelemetry/sdk-trace-base@1.17.1)(@opentelemetry/semantic-conventions@1.17.1)(effect@2.0.0-next.59): - resolution: {integrity: sha512-vDgDAmk1gNwYi5UmOHe1kOR+3qQfLV+zdg5A4hU1YlZwvkqmO2IW4NCYGxMFYgRHXRafiu/kTTiLw27ja92aUA==} + /@effect/opentelemetry@0.27.0(@opentelemetry/api@1.6.0)(@opentelemetry/resources@1.17.1)(@opentelemetry/sdk-trace-base@1.17.1)(@opentelemetry/semantic-conventions@1.17.1)(effect@2.0.0-next.60): + resolution: {integrity: sha512-qJGRWKEjG7Nseeb+gKq3NfAXNgqeWi8Q3F2u24LtA/2unwzu7cgMiCQ7Xi5r513CVbO870mwEDHdCfAVRlte0g==} peerDependencies: '@opentelemetry/api': ^1.6 '@opentelemetry/resources': ^1.17 @@ -172,7 +172,7 @@ packages: '@opentelemetry/sdk-trace-node': ^1.17 '@opentelemetry/sdk-trace-web': ^1.17 '@opentelemetry/semantic-conventions': ^1.17 - effect: 2.0.0-next.59 + effect: 2.0.0-next.60 peerDependenciesMeta: '@opentelemetry/sdk-metrics': optional: true @@ -187,7 +187,7 @@ packages: '@opentelemetry/resources': 1.17.1(@opentelemetry/api@1.6.0) '@opentelemetry/sdk-trace-base': 1.17.1(@opentelemetry/api@1.6.0) '@opentelemetry/semantic-conventions': 1.17.1 - effect: 2.0.0-next.59 + effect: 2.0.0-next.60 dev: true /@eslint-community/eslint-utils@4.4.0(eslint@8.39.0): @@ -2075,8 +2075,8 @@ packages: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} dev: true - /effect@2.0.0-next.59: - resolution: {integrity: sha512-EE87vFl0/zIN5lKDtFccU3YCnbPqjxg9rY72obNN65/GE4JOJsXciyX8XC4pIDr3lE6KeJ0le8IXf+A7d92ntQ==} + /effect@2.0.0-next.60: + resolution: {integrity: sha512-23KhlVACgrg5UPFu9i4szybSU4cCU4T/7CX4pe0jV84QBZX0zm96WzwCtg6dqOnmUzBL7hm6S+iiPW2Rab13Uw==} dev: true /electron-to-chromium@1.4.369: diff --git a/src/configuration/App-gen.ts b/src/configuration/App-gen.ts index c22013f27..c9f61f924 100644 --- a/src/configuration/App-gen.ts +++ b/src/configuration/App-gen.ts @@ -3,6 +3,6 @@ import * as HostPort from "./HostPort" // $ExpectType Effect export const program = Effect.gen(function* (_) { - const hostPort = yield* _(Effect.config(HostPort.config)) + const hostPort = yield* _(HostPort.config) console.log(`Application started: ${hostPort.url}`) }) diff --git a/src/configuration/App.ts b/src/configuration/App.ts index cea0aa1f1..3923908a2 100644 --- a/src/configuration/App.ts +++ b/src/configuration/App.ts @@ -2,7 +2,7 @@ import { Effect, Console } from "effect" import * as HostPort from "./HostPort" // $ExpectType Effect -export const program = Effect.config(HostPort.config).pipe( +export const program = HostPort.config.pipe( Effect.flatMap((hostPort) => Console.log(`Application started: ${hostPort.url}`) ) diff --git a/src/configuration/primitives-gen.ts b/src/configuration/primitives-gen.ts index 8eb789be9..1baf9743a 100644 --- a/src/configuration/primitives-gen.ts +++ b/src/configuration/primitives-gen.ts @@ -2,8 +2,8 @@ import { Effect, Config } from "effect" // $ExpectType Effect const program = Effect.gen(function* (_) { - const host = yield* _(Effect.config(Config.string("HOST"))) - const port = yield* _(Effect.config(Config.string("PORT"))) + const host = yield* _(Config.string("HOST")) + const port = yield* _(Config.string("PORT")) console.log(`Application started: ${host}:${port}`) }) diff --git a/src/configuration/primitives-pipe.ts b/src/configuration/primitives-pipe.ts index 7533d2ff9..a9740ef80 100644 --- a/src/configuration/primitives-pipe.ts +++ b/src/configuration/primitives-pipe.ts @@ -1,10 +1,7 @@ import { Effect, Config, Console } from "effect" // $ExpectType Effect -const program = Effect.all([ - Effect.config(Config.string("HOST")), - Effect.config(Config.number("PORT")) -]).pipe( +const program = Effect.all([Config.string("HOST"), Config.number("PORT")]).pipe( Effect.flatMap(([host, port]) => Console.log(`Application started: ${host}:${port}`) ) diff --git a/src/configuration/secret.ts b/src/configuration/secret.ts index f66c79361..f636abb05 100644 --- a/src/configuration/secret.ts +++ b/src/configuration/secret.ts @@ -1,6 +1,6 @@ import { Effect, Config, ConfigProvider, Layer, Console, Secret } from "effect" -const program = Effect.config(Config.secret("API_KEY")).pipe( +const program = Config.secret("API_KEY").pipe( Effect.tap((secret) => Console.log(`console.log: ${secret}`)), Effect.tap((secret) => Console.log(`Secret.value: ${Secret.value(secret)}`)) ) diff --git a/src/configuration/withDefault-gen.ts b/src/configuration/withDefault-gen.ts index 1632e84d7..8d6179a7d 100644 --- a/src/configuration/withDefault-gen.ts +++ b/src/configuration/withDefault-gen.ts @@ -1,10 +1,8 @@ import { Effect, Config } from "effect" const program = Effect.gen(function* (_) { - const host = yield* _(Effect.config(Config.string("HOST"))) - const port = yield* _( - Effect.config(Config.withDefault(Config.number("PORT"), 8080)) - ) + const host = yield* _(Config.string("HOST")) + const port = yield* _(Config.withDefault(Config.number("PORT"), 8080)) console.log(`Application started: ${host}:${port}`) }) diff --git a/src/configuration/withDefault-pipe.ts b/src/configuration/withDefault-pipe.ts index 20b5b4b1d..a3fc71207 100644 --- a/src/configuration/withDefault-pipe.ts +++ b/src/configuration/withDefault-pipe.ts @@ -1,8 +1,8 @@ import { Effect, Config, Console } from "effect" const program = Effect.all([ - Effect.config(Config.string("HOST")), - Effect.config(Config.withDefault(Config.number("PORT"), 8080)) + Config.string("HOST"), + Config.withDefault(Config.number("PORT"), 8080) ]).pipe( Effect.flatMap(([host, port]) => Console.log(`Application started: ${host}:${port}`) diff --git a/src/logging/load-log-level-from-configuration.ts b/src/logging/load-log-level-from-configuration.ts index b29c2e015..fac1a9a35 100644 --- a/src/logging/load-log-level-from-configuration.ts +++ b/src/logging/load-log-level-from-configuration.ts @@ -9,7 +9,7 @@ const program = Effect.gen(function* (_) { }) // Load the log level from the configuration as a layer -const LogLevelLive = Effect.config(Config.logLevel("LOG_LEVEL")).pipe( +const LogLevelLive = Config.logLevel("LOG_LEVEL").pipe( Effect.map((level) => Logger.minimumLogLevel(level)), Layer.unwrapEffect )