Decision is used to implement multi-version and multi-environment governance under service governance

Decision

Spring Cloud Discovery Service registration Discovery, Ribbon load balancing, Feign and RestTemplate call, etc. In addition, the routing policy is transmitted to the full-link service to access the specified service version. Decision is an environmental governance tool developed based on the open-source byteBuddy bytecode framework. It is realized by javaAgent bytecode weaving technology, which is completely transparent and non-invasive to business codes. Business codes can realize customized routing of services without modification, and the class isolation mechanism ensures the security of business codes. So as to achieve efficient and stable micro-service environment governance scheme

The target group

  • When multiple teams develop multiple services, each team needs its own development environment for timely verification and testing, resulting in high cost of development environment resources and maintenance
  • When a developer wants to debug locally, the service needs to be registered in the registry, and not every request will reach the registry, and it will affect other people’s use
  • I do not know how to select the service version when I need to grayscale the service

The source code

  • Github:github.com/IRONMAN-KD/…
  • Yards cloud: gitee.com/lkd_java/de…

Architecture is the core

Version Routing policy

Strategy description:
  • You can configure the version information about the service in the header to select the route of the service version. You can add the header information in either of the following ways: ① Add the decision. Header. version parameter based on the gateway configuration (2) Configure the header value vd-version in the HTTP request sent by the external system (for example, in Nginx, in front-end engineering, or in postman). If the header value is vd-version, the external system configuration takes precedence over the gateway configuration
  • If the version of the service in the request link is not specified in the header, the common version is selected by default (so the common version must be specified for each service). If the common version is configured and the version is not specified in the header, the corresponding service cannot be found

Env Routing Policy

Strategy description:
  • Configure the env information of the corresponding service in the header to select a route for the service. There are two ways to add the header information. Env by setting the header value vd-env in HTTP requests from external systems (such as Nginx unified configuration, front-end engineering unified configuration, or postman tools). If both modes are configured, the external system configuration takes precedence over the gateway configuration
  • If no environment is specified in the header or the specified environment is not found for the service in the request link, the common environment is selected by default. If the common version is configured and the version is not specified in the header, the corresponding service cannot be found