Class HekateConfigurer


  • @Configuration
    @ConditionalOnMissingBean(Hekate.class)
    @ConditionalOnProperty(name="hekate.enable",
                           havingValue="true",
                           matchIfMissing=true)
    public class HekateConfigurer
    extends Object
    « start hereAuto-configuration for Hekate instances.

    Overview

    This class provides support for automatic configuration and bootstrapping of Hekate instances via Spring Boot. In order to enable this auto-configuration the 'hekate-spring-boot' dependency must be added to a Spring Boot-enabled project (see 'Module dependency' section below) and @EnableHekate annotation must be placed on application class (see Usage example section below).

    Module Dependency

    Spring Boot integration is provided by the 'hekate-spring-boot' module and can be imported into the project dependency management system as in the example below:

    
     <dependency>
       <groupId>io.hekate</groupId>
       <artifactId>hekate-spring-boot</artifactId>
       <version>4.0.0</version>
     </dependency>
     
    
     compile group: 'io.hekate', name: 'hekate-spring-boot', version: '4.0.0'
     
    
     <dependency org="io.hekate" name="hekate-spring-boot" rev="4.0.0"/>
     

    Usage Example

    The code example below shows how Hekate auto-configuration can be used in a Spring Boot-enabled applications.

    First lets define some component that depends on Hekate instance.

    
    public class MyComponent {
        private final Hekate hekate;
    
        public MyComponent(Hekate hekate) {
            this.hekate = hekate;
        }
    
        @PostConstruct
        public void doSomething() {
            System.out.println("Hekate node: " + hekate.localNode());
        }
    }
    
    ...and a Spring Boot application (note the @EnableHekate annotation)...
    
    @EnableHekate // <-- Important!!!
    @SpringBootApplication
    public class MyApplication {
        public static void main(String[] args) {
            SpringApplication.run(MyApplication.class, args);
        }
    
        @Bean
        public MyComponent myComponent(Hekate hekate) {
            return new MyComponent(hekate);
        }
    }
    
    Note that Hekate instance doesn't require any manual construction.

    Registering and Configuring Services

    This class automatically registers all application-provided Beans of ServiceFactory type into the auto-configured Hekate instance.

    Additionally each service has its own auto-configuration class that simplifies configuration and registration of services and components. Please see the documentation of the following classes:

    Configuration Options

    The following application properties can be used to configure the constructed Hekate instance:

    Deferred Cluster Joining

    It is possible to control the timing of when Hekate node will start joining the cluster by specifying the following properties:

    • 'hekate.deferred-join' - if set to false (default value) then joining will happen synchronously during the Spring Application context initialization
    • 'hekate.deferred-join' - if set to true then joining will be deferred until the Spring Application context gets fully initialized (signalled by ApplicationReadyEvent).

    Furthermore it is also possible to completely disable joining to the cluster by setting the 'hekate.deferred-join-condition' property value to 'manual'. In such case it is up to the application logic to decide on when to call the Hekate.join() method in order to start joining the cluster. Alternative value of this property is 'app-ready' which will fall back to the default behavior.