Skip to content

Add cache collector #711

@lublak

Description

@lublak

For complexer work it would be nice to have something like this:

cache_collector:
  resource: cache_resource
  key: ""
  init: root = []
  append_check: this.process == "work"
  append_map: root = this.old.append(this.new)
  flush_check: this.process == "end"
  flush_deletes: true
  flush_map: root = this

logic for each message (process):

  • get cache by resource config
  • check if append_check returns true on current message
  • if append_check bloblang returns true
    • read the key from key config in cache as current value
    • if not exists call the bloblang init function which is now the current value
    • call append_map bloblang function with "this.old" (the current value) and "this.new" (the current message), the return value is then the current value
    • store the value into the cache
    • return nothing from processing (no message)
  • if flush_check bloblang true
    • read the key from key config in cache as current value
    • if not exists call the bloblang init function which is now the current value
    • if flush_deletes is true the cache key gets removed
    • call flush_map bloblang function which returns from processing the new message (replaces the current message)
  • if both checks are not true
    • just return the message as it is

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions