Class CachedCrnStringPatternMatcher<T>

java.lang.Object
io.confluent.crn.CachedCrnStringPatternMatcher<T>

public class CachedCrnStringPatternMatcher<T> extends Object
In practice, we will usually be routing messages based on the string CRN values in CloudEvent subject fields. This cache avoids the expense of parsing those strings into ConfluentResourceNames, and the expense of re-evaluating the CRN against a probably-unchanging set of rules.

We assume that the number of unique subjects that we'll route based on is not unreasonably large. There may be, eg. tens of thousands of topics, but not billions. We use an LRU to make sure we don't expand the cache indefinitely.

  • Constructor Details

    • CachedCrnStringPatternMatcher

      public CachedCrnStringPatternMatcher(CrnPatternMatcher<T> matcher, int capacity)
      Create a cache with the desired capacity. The capacity should be tuned to the number of unique CRNs that will be matched, not the number of patterns they will be matched against. If you have 1000 different topics, but 10 rules, the capacity should be > 1000.
  • Method Details