Account subject mappings and full wildcard support for exports/imports

The mappings enable traffic shaping functionality.
Also added a subject transform which can match any subject and transform to a new one, even re-ordering partial wildcards.

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2020-07-03 10:31:55 -07:00
parent fe7fd92c89
commit 6faf07d583
10 changed files with 1362 additions and 86 deletions

View File

@@ -389,6 +389,17 @@ func (c *client) parse(buf []byte) error {
if err := c.processPub(arg); err != nil {
return err
}
// Check if we have and account mappings or tees or filters.
// FIXME(dlc) - Probably better way to do this.
// Could add in cache but will be tricky since results based on pub subject are dynamic
// due to wildcard matching and weight sets.
if c.kind == CLIENT && c.in.flags.isSet(hasMappings) {
old := c.pa.subject
changed := c.selectMappedSubject()
if trace && changed {
c.traceInOp("MAPPING", []byte(fmt.Sprintf("%s -> %s", old, c.pa.subject)))
}
}
c.drop, c.as, c.state = 0, i+1, MSG_PAYLOAD
// If we don't have a saved buffer then jump ahead with
// the index. If this overruns what is left we fall out