Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

io.jmnarloch:zuul-trie-matcher-spring-cloud-starter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io.jmnarloch:zuul-trie-matcher-spring-cloud-starter

Spring Cloud Netflix Zuul Trie Matcher

  • 1.2.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Spring Cloud Zuul Trie route matcher

A Spring Cloud Trie route matcher

Build Status Coverage Status

Features

Extends the Spring Cloud's ProxyRouteLocator with configurable matching strategy. The provided implementation allows to register a Trie tree for matching the routes.

Setup

Add the Spring Cloud starter to your project:

<dependency>
  <groupId>io.jmnarloch</groupId>
  <artifactId>zuul-trie-matcher-spring-cloud-starter</artifactId>
  <version>1.1.2</version>
</dependency>

Enable the Zuul proxy with @EnableZuulProxyMatcher - use this annotation as a replacement for standard @EnableZuulProxy, the only requirement to use this component is to register a concrete bean of type RouteMatcher

@EnableZuulProxyMatcher
@SpringBootApplication
public static class Application {

    @Bean
    public RouteMatcher routeMatcher() {
        return new TrieRouteMatcher(() -> Tries.newCharHashMapTrie());
    }
}

Except for that everything is generally the same as when used with standard Zuul proxy.

Implementation details

The Trie is a R way tree that is designed for efficient string searches, perfectly fitting for use cases like Zuul route path matching. For most effective use the Trie is being build on application context refresh and used for queries afterwards.

At this moment this component defines three different implementation of the Trie, all of which differs slightly in performance, but far most with the memory consumption.

The available Trie implementations are:

  • CharArrayTrie
  • HashMapTrie
  • CharHashMapTrie - that uses Trove TCharObjectHashMap

Performance characteristics

The standard implementation of ProxyRouteLocator iterates over every ZuulProperties.ZuulRoute in order to find the first one matching the request URI. If we denote N - as number of routes and M as the maximum path length then we can say that finding the path takes O(NM) time in worst case.

The proposed alternative will replace this path finding by performing prefix search on the Trie tree, with running time of O(M) in worst case, the performance gains are made in exchange of extra memory usage.

Also the side effect of using the Trie is that it allows to define overlapping paths for instance:

  • /uaa/**
  • /uaa/account/**

As already stated the standard implementation would chose either of those paths depending on the order they have been defined in properties file, the Trie tree in contrary would find the best matching route i.e. for path /uaa/authorize, /uaa/** would be used and for /uaa/account/j.doe, /uaa/account/** is going to be matched.

License

Apache 2.0

FAQs

Package last updated on 01 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc