
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@equinor/fusion-framework-module-service-discovery
Advanced tools
This module is for resolving service endpoints from a service discovery service.
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.
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 */ }
)
);
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);
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'
);
});
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'
};
}
);
});
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}`);
}
};
}
);
});
FAQs
This module is for resolving service endpoints from a service discovery service.
The npm package @equinor/fusion-framework-module-service-discovery receives a total of 1,155 weekly downloads. As such, @equinor/fusion-framework-module-service-discovery popularity was classified as popular.
We found that @equinor/fusion-framework-module-service-discovery demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.