Skip to content

spotinst/spotinst-metrics

Repository files navigation

Spotinst Java Service Template

Template project for creating a new Spotinst Java service.

spotinst-logo java-icon

What is it?

This project intended to be used when in need to create a new Java service.
It encapsulate the following Spotinst internal libraries:

Requirements

  • Java 21

Getting Started

  1. Git clone
  2. Rename package to com.spotinst.<service-name>
  3. Rename all SampleXXX classes to proper service name
  4. Remove irrelevant content

Renaming Service Name

  1. In settings.gradle change the rootProject.name name
  2. Rename IntelliJ module to proper service name
  3. Git push

Notes

The template contains optional content such as customer facing service filters, rate limit filters/tasks etc..
When not in need, these classes should get removed from the project.

Configuration

Service configuration YAML files contains coverage of all possible components exists on the java-service-template.
Make sure to remove unnecessary configuration and un-comment the ones that in need for the new service.

What's included in the service configuration?

  • Credentials/Tokens
  • Services URLs
  • HTTP Client
  • Rate Limiter
  • Feature Flags
  • Dropwizard Web Server
  • Messaging Producer/Consumer
  • Logging

Repositories

Repositories should be created under package com.spotinst.<service>.bl.repos and registered to xxxRepoManager.
Every repository class name should comply to the IxxxRepo format and it's property name should be the name of the entity it represents:

public class SampleRepoManager extends BaseRepoManager {
    
    public static IOrganizationRepo Organization;
    ...
}

There are two alternatives when creating a new repository:

  1. Create a standard repository with full implementation
  2. Optional: GenericRepo for basic CRUD based entities

Converters

Model conversion can be used by two different approaches:

  • Orika mapper is available on the template project for mapping Java models with partial update support
  • Manual conversion methods

Make sure to follow coding guidelines by encapsulating entity mappings behaviour API <--> BL <--> DAL inside a single converter class.

Releases

No releases published

Packages

No packages published