Giter Club home page Giter Club logo

Comments (6)

ronenhamias avatar ronenhamias commented on June 26, 2024

after microservices has started its already an immutable object.
microservices are automatically registered and discovered within a node and they publish locally and remotely the services they host within a Microservices node in the network of microservices based on SWIM.

you can checkout the examples and the tests inside the project

https://github.com/scalecube/scalecube-services/tree/master/services-examples

the main idea is that any node can be a seed one address that allows all services to join the cluster of services.
using gossip and SWIM discovery protocol once a member joined the cluster all other members automatically aware of it
it means that seed is only used for first handshake and act as a well known address to join the cluster
after this there is no need of seed until next member want to join.
so its not mandatory to join the cluster via seed in case somehow you know the address of the any node.

when a member joins a cluster he can just start or start pointing to some seed member.
final Address seedAddress = seed.discovery().address();

     .membership(cfg -> cfg.seedMembers(seedAddress)))
  // ScaleCube Node with no members
    Microservices seed =
        Microservices.builder()
            .discovery(
                serviceEndpoint ->
                    new ScalecubeServiceDiscovery()
                        .transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
                        .options(opts -> opts.metadata(serviceEndpoint)))
            .transport(RSocketServiceTransport::new)
            .startAwait();

    final Address seedAddress = seed.discovery().address();

    // Construct a ScaleCube node which joins the cluster hosting the Greeting Service
    Microservices ms =
        Microservices.builder()
            .discovery(
                "ms",
                endpoint ->
                    new ScalecubeServiceDiscovery()
                        .transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
                        .options(opts -> opts.metadata(endpoint))
                        .membership(cfg -> cfg.seedMembers(seedAddress)))
            .transport(RSocketServiceTransport::new)
            .services(new GreetingServiceImpl())
            .startAwait();
``

from scalecube-services.

zhou-hao avatar zhou-hao commented on June 26, 2024

Sorry,Maybe you don't understand my scenes.

ServiceMethodRegistry registry = new ServiceMethodRegistryImpl();

Microservices ms =
        Microservices.builder()
            .discovery(
                "ms",
                endpoint ->
                    new ScalecubeServiceDiscovery()
                        .transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
                        .options(opts -> opts.metadata(endpoint))
                        .membership(cfg -> cfg.seedMembers(seedAddress)))
            .transport(RSocketServiceTransport::new)
            .methodRegistry(registry)
            .startAwait();
            
// register a service after Microservices started
  registry.registerService(ServiceInfo
                                 .fromServiceInstance(new GreetingServiceImpl())
                                  ....
                                 .build())

from scalecube-services.

ronenhamias avatar ronenhamias commented on June 26, 2024

ohh i see
once microservices is started its immutable.
so any change that is done to method registry will not take effect.
this is because on start there is introspection of the microservices and registration of them to the cluster.
so adding anything to the registry after start does not make any sense.

from scalecube-services.

zhou-hao avatar zhou-hao commented on June 26, 2024

MembershipEvent has UPDATED Type, Is there a plan to support ServiceDiscoveryEvent.Type ?

private ServiceDiscoveryEvent toServiceDiscoveryEvent(MembershipEvent membershipEvent) {
ServiceDiscoveryEvent discoveryEvent = null;
if (membershipEvent.isAdded() && membershipEvent.newMetadata() != null) {
discoveryEvent = newEndpointAdded(decodeMetadata(membershipEvent.newMetadata()));
}
if (membershipEvent.isRemoved() && membershipEvent.oldMetadata() != null) {
discoveryEvent = newEndpointRemoved(decodeMetadata(membershipEvent.oldMetadata()));
}
if (membershipEvent.isLeaving() && membershipEvent.newMetadata() != null) {
discoveryEvent = newEndpointLeaving(decodeMetadata(membershipEvent.newMetadata()));
}
return discoveryEvent;

from scalecube-services.

ronenhamias avatar ronenhamias commented on June 26, 2024

scalecube is an open source project - anyone is welcome to fork/offer improvements.
pull request are considered/accepted with a reasoning what is the motivation for the improvement.

from scalecube-services.

zhou-hao avatar zhou-hao commented on June 26, 2024

from scalecube-services.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.