Skip to content

Commit

Permalink
Remove fucntion_exported? check for Keyword.validate!/2 (#186)
Browse files Browse the repository at this point in the history
Gnat already requires Elixir 1.14, so we're safe to remove
  • Loading branch information
davydog187 authored Jan 9, 2025
1 parent 3559640 commit a21ab91
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions lib/gnat/jetstream/pull_consumer/connection_options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,18 @@ defmodule Gnat.Jetstream.PullConsumer.ConnectionOptions do

defstruct @enforce_keys

# Remove this hackery when we will support Elixir ~> 1.13 only.
if Kernel.function_exported?(Keyword, :validate!, 2) do
def validate!(connection_options) do
struct!(
__MODULE__,
Keyword.validate!(connection_options, [
:connection_name,
:stream_name,
:consumer_name,
connection_retry_timeout: @default_retry_timeout,
connection_retries: @default_retries,
inbox_prefix: nil,
domain: nil
])
)
end
else
def validate!(connection_options) do
struct!(
__MODULE__,
Keyword.merge(
[
connection_retry_timeout: @default_retry_timeout,
connection_retries: @default_retries,
inbox_prefix: nil,
domain: nil
],
connection_options
)
)
end
def validate!(connection_options) do
struct!(
__MODULE__,
Keyword.validate!(connection_options, [
:connection_name,
:stream_name,
:consumer_name,
connection_retry_timeout: @default_retry_timeout,
connection_retries: @default_retries,
inbox_prefix: nil,
domain: nil
])
)
end
end

0 comments on commit a21ab91

Please sign in to comment.