Skip to content

Commit

Permalink
filter out unsupported policies
Browse files Browse the repository at this point in the history
  • Loading branch information
kickster97 committed Nov 22, 2023
1 parent dacac51 commit 7551959
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lavinmq/policy.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module LavinMQ
end

class Policy
SUPPORTED_POLICIES = ["max-length", "max-length-bytes", "message-ttl", "expires", "overflow",
"dead-letter-exchange", "dead-letter-routing-key", "federation-upstream",
"federation-upstream-set", "delivery-limit", "max-age",
"alternate-exchange", "delayed-message"]
enum Target
All
Queues
Expand Down Expand Up @@ -67,15 +71,15 @@ module LavinMQ
merged[k] = v
end
end
merged
merged.select { |key, _| SUPPORTED_POLICIES.includes?(key) }
end

def self.merge_definitions(p1 : Nil, p2 : Policy) : Hash(String, JSON::Any)
p2.definition
p2.definition.select { |key, _| SUPPORTED_POLICIES.includes?(key) }
end

def self.merge_definitions(p1 : Policy, p2 : Nil) : Hash(String, JSON::Any)
p1.definition
p1.definition.select { |key, _| SUPPORTED_POLICIES.includes?(key) }
end

def self.merge_definitions(p1 : Nil, p2 : Nil) : Hash(String, JSON::Any)
Expand Down

0 comments on commit 7551959

Please sign in to comment.