From d25304735bdb64fa8cbcdea34b27b726f01b7fdc Mon Sep 17 00:00:00 2001 From: Indrek Juhkam Date: Mon, 1 Jul 2024 22:31:12 +0300 Subject: [PATCH] Fix type spec in brod_transaction `brod:transaction` spec is: ```erlang -spec transaction(client(), transactional_id(), transaction_config()) -> {ok, transaction()}. ``` and brod_transaction:init also has: ```erlang init({Client, TxId, PropListConfig}) -> ClientPid = pid(Client), ``` but new and start_link were expecting only a pid. The client() spec itself is: ```erlang -type client() :: client_id() | pid(). ``` --- src/brod_transaction.erl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/brod_transaction.erl b/src/brod_transaction.erl index 11c1ad81..3ff5ce5a 100644 --- a/src/brod_transaction.erl +++ b/src/brod_transaction.erl @@ -133,10 +133,10 @@ %%============================================================================== %% @see start_link/3 --spec new(pid(), transactional_id(), transaction_config()) -> {ok, transaction()}. -new(ClientPid, TxId, Config) -> +-spec new(client(), transactional_id(), transaction_config()) -> {ok, transaction()}. +new(Client, TxId, Config) -> gen_server:start_link(?MODULE, - {ClientPid, TxId, Config}, + {Client, TxId, Config}, []). %% @doc Start a new transaction, `TxId'will be the id of the transaction @@ -145,9 +145,9 @@ new(ClientPid, TxId, Config) -> %% `backoff_step': after each retry it will sleep for 2^Attempt * backoff_step %% millis %% `max_retries' --spec start_link(pid(), transactional_id(), transaction_config()) -> {ok, pid()}. -start_link(ClientPid, TxId, Config) -> - gen_server:start_link(?MODULE, {ClientPid, TxId, Config}, []). +-spec start_link(client(), transactional_id(), transaction_config()) -> {ok, pid()}. +start_link(Client, TxId, Config) -> + gen_server:start_link(?MODULE, {Client, TxId, Config}, []). %% @doc Produce the message (key and value) to the indicated topic-partition %% synchronously.