Class: Karafka::Web::Pro::Ui::Lib::Policies::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/web/pro/ui/lib/policies/messages.rb

Overview

Allows for a granular control over what parts of messages are being displayed and operated on. There are scenarios where payload or other parts of messages should not be presented because they may contain sensitive data. This API allows to manage that on a per message basis.

Instance Method Summary collapse

Instance Method Details

#download?(message) ⇒ Boolean

Should it be allowed to download this message raw payload

Parameters:

  • message (::Karafka::Messages::Message)

Returns:

  • (Boolean)

    true if downloads allowed



48
49
50
# File 'lib/karafka/web/pro/ui/lib/policies/messages.rb', line 48

def download?(message)
  payload?(message)
end

#export?(message) ⇒ Boolean

Should it be allowed to download the deserialized and sanitized payload as JSON

Parameters:

  • message (::Karafka::Messages::Message)

Returns:

  • (Boolean)

    true if exports allowed



56
57
58
# File 'lib/karafka/web/pro/ui/lib/policies/messages.rb', line 56

def export?(message)
  payload?(message)
end

#headers?(_message) ⇒ Boolean

Returns should message headers be visible.

Parameters:

  • _message (::Karafka::Messages::Message)

Returns:

  • (Boolean)

    should message headers be visible



34
35
36
# File 'lib/karafka/web/pro/ui/lib/policies/messages.rb', line 34

def headers?(_message)
  true
end

#key?(_message) ⇒ Boolean

Returns should message key be visible.

Parameters:

  • _message (::Karafka::Messages::Message)

Returns:

  • (Boolean)

    should message key be visible



28
29
30
# File 'lib/karafka/web/pro/ui/lib/policies/messages.rb', line 28

def key?(_message)
  true
end

#payload?(message) ⇒ Boolean

Returns should message payload be visible.

Parameters:

  • message (::Karafka::Messages::Message)

Returns:

  • (Boolean)

    should message payload be visible



40
41
42
# File 'lib/karafka/web/pro/ui/lib/policies/messages.rb', line 40

def payload?(message)
  !message.headers.key?('encryption')
end

#republish?(_message) ⇒ Boolean

Note:

This is a simple API that does not provide granular republishing support. You can decide whether to allow for republishing but you cannot say “allow only to X”, etc.

Should we allow to republish given message

Parameters:

  • _message (::Karafka::Messages::Message)

Returns:

  • (Boolean)

    true if we should allow republishing



67
68
69
# File 'lib/karafka/web/pro/ui/lib/policies/messages.rb', line 67

def republish?(_message)
  true
end