@scalecube/benchmark
v0.0.1
Published
This package provides Scalecube's solution with default setting for working in node.
Downloads
1
Maintainers
Keywords
Readme
This is part of scalecube-js project, see more at https://github.com/scalecube/scalecube-js
Full documentation
Microservices-browser
This package provides Scalecube's solution with default setting for working in node.
Usage
yarn add @scalecube/node
or npm i @scalecube/node
import { createMicroservice, ASYNC_MODEL_TYPES } from '@scalecube/node';
create a seed
export const MySeedAddress: 'ws://localhost:8000';
// Create a service
createMicroservice({
address : MySeedAddress
});
Create a service
// Create service definition
export const greetingServiceDefinition = {
serviceName: 'GreetingService',
methods: {
hello: {
asyncModel: ASYNC_MODEL_TYPES.REQUEST_RESPONSE,
}
},
};
// Create a service
createMicroservice({
service : [{
definition: greetingServiceDefinition,
reference: {
hello : (name) => `Hello ${name}`
},
}],
seedAddress : MySeedAddress,
address : 'ws://localhost:8001'
});
Use a service
const microservice = createMicroservice({
seedAddress : MySeedAddress,
address : 'ws://localhost:8002'
})
// With proxy
const greetingService = microservice.createProxy({
serviceDefinition: greetingServiceDefinition
});
greetingService.hello('ME').then(console.log) // Hello ME
Dependency Injection
createMicroservice({
seedAddress : MySeedAddress,
address : 'ws://localhost:8003',
services: [
{
definition: serviceB,
reference: ({ createProxy, createServiceCall }) => {
const greetingService = createProxy({serviceDefinition: greetingServiceDefinition });
return new ServiceB(greetingService);
}
}
]
})
documentation
please Read before starting to work with scalecube.