Scalecube v0.2.x is stable, the API will be supported until 1.1.2021.
We want to collect feedback from the community before releasing 1.x.x but we don't foresee any majors API change.
If you have any feedback please open issue
Scalecube is a toolkit for creating microservices/micro-frontends based systems.
Full documentation
We provide browser and NODE templates, configured and ready for use
yarn add @scalecube/browser
or npm i @scalecube/browser
import { createMicroservice, ASYNC_MODEL_TYPES } from '@scalecube/browser';
yarn add @scalecube/node
or npm i @scalecube/node
import { createMicroservice, ASYNC_MODEL_TYPES } from '@scalecube/node';
You can create your own customized setup, for more details: go to Microservice:
create a seed
// node - supported WS, WSS and TCP
export const MySeedAddress: 'ws://localhost:8000';
// Browser - under browser post message will be used as transport
export const MySeedAddress: 'seed';
// 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
});
Use a service
const microservice = createMicroservice({seedAddress : MySeedAddress})
// With proxy
const greetingService = microservice.createProxy({
serviceDefinition: greetingServiceDefinition
});
greetingService.hello('ME').then(console.log) // Hello ME
*We let Scalecube choose our addresses for us, we know only the seed address.
After we connected to the seed we will see the whole cluster.
In the browser we don't need to import modules, we can create multiple bundles, scalecube will discover the available services
*NOTICE For Node you have to set addresses, there isn't any default at the moment
Dependency Injection
createMicroservice({
seedAddress : MySeedAddress,
services: [
{
definition: serviceB,
reference: ({ createProxy, createServiceCall }) => {
const greetingService = createProxy({serviceDefinition: greetingServiceDefinition });
return new ServiceB(greetingService);
}
}
]
})
For more examples go to examples or full documentation
Router,
Discovery,
Transport-browser,
Transport-nodejs,
Gateway,
Cluster-browser,
Cluster-nodejs.
MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards-compatible manner, and
PATCH version when you make backwards-compatible bug fixes.