8.0.17 • Published 4 months ago

@equinor/fusion-framework-module-service-discovery v8.0.17

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

Fusion Service Discovery Module

This module is for resolving service endpoints from a service discovery service.

!WARNING This module requires @equinor/fusion-framework-module-http to to create http clients, so the module must be enabled in runtime.

Configure

This module requires a http client to be configured. The http client should be configured with a key that is used to resolve the service endpoints.

!NOTE The Service Discovery Module inherits configuration when used in sub-modules (ex. Application), which means that the http client should be configured in the root module (ex Portal).

Skip this step if the http client is already configured.

import { ModulesConfigurator } from '@equinor/fusion-framework-module';
const configurator = new ModulesConfigurator();
configurator.addConfig(
    configureHttpClient(
      'service_discovery', 
      { /* http config */ }
    )
);

Simple Configuration

In the simplest form, the service discovery module can be enabled with the following code:

import enableServiceDiscovery from '@equinor/fusion-framework-service-discovery';

// the module will setup the service discovery client with default configuration
// Assumes that http client is configured with key 'service_discovery'
enableServiceDiscovery(configurator);

Override default http client key

If the http client is configured with a different key, the key can be specified as follows:

enableServiceDiscovery(
  configurator, 
  async(builder: ServiceDiscoveryConfigurator) => {
    builder.configureServiceDiscoveryClientByClientKey(
      // assume that http client is configured with this key
      'service_discovery_custom', 
      // optional endpoint path
      '/custom/services' 
    );
});

Advanced Configuration

Override default http client

If a custom http client is required, the client can be configured as follows:

enableServiceDiscovery(
  configurator, 
  async(builder: ServiceDiscoveryConfigurator) => {
    builder.configureServiceDiscoveryClient(
      // configurator callback
      async (args: ConfigBuilderCallbackArgs) => {
        // using build environment to create a http client
        const httpProvider = await requireInstance('http');
        const httpClient = httpProvider.createClient('some_key');
        return { 
          httpClient: httpProvider.createClient('some_key'),
          endpoint: '/custom/services'
        };
      }
    );
});

Setting a custom service discovery client

If a custom service discovery client is required, the client can be configured as follows:

enableServiceDiscovery(
  configurator, 
  async(builder: ServiceDiscoveryConfigurator) => {
    builder.setServiceDiscoveryClient(
      {
        resolveServices() {
          return [
            { 
              key: 'service1', 
              url: 'http://service1.com' 
            },
            { 
              key: 'service2', 
              url: 'http://service2.com' 
            }
          ]
        },
        resolveService(key: string): Promise<ServiceEndpoint> {
          return this.services.find(s => s.key === key);
        }
      }
    );
});

If custom logic for creating the service discovery client is required, the client can be configured as follows:

enableServiceDiscovery(
  configurator, 
  async(builder: ServiceDiscoveryConfigurator) => {
    builder.setServiceDiscoveryClient(
      async(args: ConfigBuilderCallbackArgs) => {
        const httpProvider = await requireInstance('http');
        const httpClient = httpProvider.createClient('my_key');
        return {
          resolveServices() {
            return httpClient.get('/services');
          },
          resolveService(key: string): Promise<ServiceEndpoint> {
            return httpClient.get(`/services/${key}`);
          }
        };
      }
    );
});
8.0.15-next.0

5 months ago

8.0.15-next.1

5 months ago

8.0.15-next.2

5 months ago

8.0.10

6 months ago

8.0.12

6 months ago

8.0.11

6 months ago

8.0.14

5 months ago

8.0.13

5 months ago

8.0.16

5 months ago

8.0.15

5 months ago

8.0.17

4 months ago

8.0.9

7 months ago

8.0.8

7 months ago

8.0.5

9 months ago

8.0.4

10 months ago

8.0.7

8 months ago

8.0.6

8 months ago

8.0.3

11 months ago

8.0.2

11 months ago

7.1.7

1 year ago

7.1.9

1 year ago

7.1.8

1 year ago

7.1.13

1 year ago

7.1.11

1 year ago

7.1.12

1 year ago

7.1.10

1 year ago

8.0.1

1 year ago

8.0.0

1 year ago

7.1.6

1 year ago

7.1.5

1 year ago

7.1.4

1 year ago

7.1.3

2 years ago

7.1.2

2 years ago

7.1.1

2 years ago

7.1.0

2 years ago

7.0.20

2 years ago

7.0.19

2 years ago

7.0.18

2 years ago

7.0.17

2 years ago

7.0.16

2 years ago

7.0.15

2 years ago

7.0.14

2 years ago

7.0.8

2 years ago

7.0.7

2 years ago

7.0.9

2 years ago

7.0.12

2 years ago

7.0.13

2 years ago

7.0.10

2 years ago

7.0.11

2 years ago

7.0.5

2 years ago

7.0.0

3 years ago

7.0.4

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.8

3 years ago

7.0.1-next.3

2 years ago

7.0.1-next.2

2 years ago

7.0.1-next.4

2 years ago

7.0.1-next.1

2 years ago

7.0.1-next.0

2 years ago

6.0.3

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

4.0.5

3 years ago

4.0.4

3 years ago

4.0.7

3 years ago

4.0.6

3 years ago

4.0.1

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

5.0.4

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.8

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

6.0.2

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0-alpha.0

3 years ago

2.0.0

3 years ago

3.2.2

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.10

3 years ago

3.0.2

3 years ago

3.0.11

3 years ago

3.0.1

3 years ago

3.2.6

3 years ago

3.0.8

3 years ago

3.2.5

3 years ago

3.0.7

3 years ago

3.2.4

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

1.0.1-next.1

3 years ago

3.0.0

3 years ago

4.0.0

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

3.2.9

3 years ago

3.2.8

3 years ago

3.2.7

3 years ago

3.0.9

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.1.4

3 years ago

3.2.11

3 years ago

3.2.10

3 years ago

0.3.9

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.3.0

3 years ago

0.3.6

3 years ago

0.6.2

3 years ago

0.3.5

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.5.0

3 years ago

0.3.2

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.3.4

3 years ago

0.6.0

3 years ago

0.3.3

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.1.0-beta.15

4 years ago

0.1.0-beta.14

4 years ago

0.1.0-beta.12

4 years ago

0.1.0-beta.11

4 years ago

0.1.0-beta.9

4 years ago

0.1.0-beta.7

4 years ago

0.1.0-beta.4

4 years ago

0.1.0-beta.3

4 years ago

0.1.0-beta.2

4 years ago

0.1.0-beta.1

4 years ago

0.1.0-alpha.0

4 years ago

0.1.0-beta.0

4 years ago

0.1.0-alpha.12

4 years ago

0.1.0-alpha.11

4 years ago

0.1.0-alpha.10

4 years ago

0.1.0-alpha.9

4 years ago

0.1.0-alpha.7

4 years ago

0.1.0-alpha.6

4 years ago

0.1.0-alpha.5

4 years ago