Giter Club home page Giter Club logo

vaunt's Introduction

Vaunt

Build Status Coverage Status License: MIT Scrutinizer Code Quality

Table of Contents

  1. Overview
  2. Idea
  3. Built with
  4. Authors
  5. License

Overview

This repository contains toolkit to define and validate contracts in JMS

Idea

There are 3 most typical scenarios and any other scenario is a combination of these 3.

Scenario I: Service 1 -> Queue A -> Service 2
Scenario II: Service 3 -> Topic B -> Service 4
Scenario III: Service 5 -> Topic C -> Queue D -> Service 6

In Scenario I Service 1 sends commands to Queue A. Service 2 handles these commands.
In Scenario II Service 3 publishes events to Topic B. Service 4 listens to the events.
In Scenario III Service 5 publishes events to Topic C. They are sent further to Queue D and Service 6 listens to the events.

A provider is a service providing functionality to other services.
A consumer is a service depending on functionality provided by the provider.
What does it mean from the perspective of 3 specified scenarios?
In scenario I Service 2 is the provider. It accepts commands (to perform a task) via its queue from Service 1, which is a consumer of its functionality.
In scenario II Service 3 is the provider. Events generated by Service 3 are consumed by Service 4, therefore Service 4 is the consumer.
In scenario III situation is similar like in scenario II. Queue D is an internal concern of Service 6. This scenario may be simplified to the following one:
Scenario IIIb: Service 5 -> Topic C -> (Queue D) Service 6
As a result, Service 5 is the provider, service 6 is the consumer.

A contract contains:

  • Provider's JMS destination type: topic/queue/temporary queue
  • Provider's JMS destination name (omitted in case of temporary queues)
  • Message id (by default name of the class representing message, can be customized)
  • JSON schema of a message exchanged between consumer and provider

Capabilities of a provider should contain the contract.
Expectations of a consumer should contain the contract and name of the provider.

Annotations @Consumer and @Provider should be used on messages exchanged between consumer and provider. One message can be annotated with multiple annotations For now classes representing messages should have the same name. Objects belonging to other via composition might have different names (ids).

It is possible to provide properties with JMS destination names.

Fields contained in message on provider side must be a superset of fields contained in message on consumer side. Same applies to enums. Enum on provider side can be represented by String as well. It requires setting DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL in ObjectMapper (or equivalent) in producer and @JsonIgnoreProperties(ignoreUnknown = true) (or equivalent) in case of Strings.

Vaunt-Generator does not use "ref" (i. e. uses inlining) with the exception of JsonSchema (threat of StackOverflow).

Currently Vaunt Validator supports BooleanSchema, IntegerSchema, NumberSchema, ObjectSchema, StringSchema, ArraySchema.

Vaunt validator validates in order how contract is specified i.e. when expectations are verified and no capabilities match them, then in results the most similar expectations and corresponding errors are displayed

Example of code snippet with test creating Vaunt contract

@SpringBootTest
class GenerateVauntIT extends Specification {

    @Autowired
    Environment env

    @Autowired
    private ApplicationContext applicationContext

    @Subject
    VauntGenerator vauntGenerator = new VauntGenerator()

    def 'should generate vaunt file'() {
        expect:
            YAMLConfiguration config = new YAMLConfiguration()
            config.read(new FileInputStream("src/main/resources/application.yml"))

            def props = new Properties()
            for(String key : config.getKeys()) {
                props.put(key, env.getProperty(key))
            }

            vauntGenerator.writeVauntFile('com.hltech.sample.component', 'sample-component', 'target/classes/static/vaunt', props)
    }
}

Built with

  • Gradle - dependency management & build tool

Authors

License

vaunt is MIT licensed.

vaunt's People

Contributors

felipe444 avatar garlicsauce avatar matek2305 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

felipe444

vaunt's Issues

Validation result fix

dst name
dst type
name of main class representing message

should be in correct validation result

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.