Skip to content

Commit

Permalink
Cleanup code and version update
Browse files Browse the repository at this point in the history
  • Loading branch information
silviucpp committed Jul 26, 2024
1 parent 35daac2 commit ac3f3c7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
### Changelog:

#### 2.1.6

- OAuthbearer support (contribution from macasado86 : https://github.com/silviucpp/erlkaf/pull/74)

#### 2.1.5

- Bug fixing: brew install causing undesired updates and crashing other Homebrew pkgs (https://github.com/silviucpp/erlkaf/issues/68)
[- Bug fixing: brew install causing undesired updates and crashing other Homebrew pkgs (https://github.com/silviucpp/erlkaf/issues/68)
- Update travis config
- Bug fixing: https://github.com/silviucpp/erlkaf/pull/71
- Bug fixing: https://github.com/silviucpp/erlkaf/pull/71]()

#### 2.1.4

Expand Down
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# erlkaf
[![Build Status](https://travis-ci.com/silviucpp/erlkaf.svg?branch=master)](https://travis-ci.com/github/silviucpp/erlkaf)
[![Build Status](https://app.travis-ci.com/silviucpp/erlkaf.svg?branch=master)](https://travis-ci.com/github/silviucpp/erlkaf)
[![GitHub](https://img.shields.io/github/license/silviucpp/erlkaf)](https://github.com/silviucpp/erlkaf/blob/master/LICENSE)
[![Hex.pm](https://img.shields.io/hexpm/v/erlkaf)](https://hex.pm/packages/erlkaf)

Expand Down
8 changes: 3 additions & 5 deletions c_src/erlkaf_consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include <future>
#include <string.h>
#include <unistd.h>
#include <sstream>
#include <iostream>

namespace {

Expand Down Expand Up @@ -111,7 +109,7 @@ void assign_partitions(ErlNifEnv* env, enif_consumer* consumer, rd_kafka_t *rk,
rd_kafka_assign(rk, NULL);
return;
}

rd_kafka_resp_err_t response = rd_kafka_assign(rk, partitions);

if(response != RD_KAFKA_RESP_ERR_NO_ERROR)
Expand Down Expand Up @@ -184,7 +182,7 @@ void oauthbearer_token_refresh_callback(rd_kafka_t *rk, const char *oauthbearer_
ERL_NIF_TERM config = make_binary(env, oauthbearer_config, strlen(oauthbearer_config));
enif_send(NULL, &consumer->owner, env, enif_make_tuple2(env, ATOMS.atomOauthbearerTokenRefresh, config));
}

enif_free_env(env);
}

Expand Down Expand Up @@ -471,7 +469,7 @@ ERL_NIF_TERM enif_consumer_cleanup(ErlNifEnv* env, int argc, const ERL_NIF_TERM
ERL_NIF_TERM enif_consumer_oauthbearer_set_token(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
UNUSED(argc);

std::string token;
long lifetime;
std::string principal;
Expand Down
4 changes: 4 additions & 0 deletions c_src/erlkaf_oauthbearer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <sstream>
#include <iostream>

namespace {

char** split_extensions(const std::string extensions_str, size_t* length)
{
std::stringstream extensions_stream(extensions_str);
Expand Down Expand Up @@ -44,6 +46,8 @@ void free_extensions(char** extensions, size_t length)
}
}

}

ERL_NIF_TERM oauthbearer_set_token(rd_kafka_t* kf, std::string token, long lifetime, std::string principal, std::string extensions_str)
{
char set_token_errstr[512];
Expand Down
3 changes: 0 additions & 3 deletions c_src/erlkaf_producer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include <memory>
#include <string>
#include <future>
#include <vector>
#include <sstream>
#include <iostream>

namespace {

Expand Down
2 changes: 1 addition & 1 deletion src/erlkaf.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{description, "erlkaf - Erlang Kafka library based on librdkafka"},
{licenses, ["MIT"]},
{links,[{"Github","https://github.com/silviucpp/erlkaf"}]},
{vsn, "2.1.5"},
{vsn, "2.1.6"},
{registered, []},
{applications, [
kernel,
Expand Down
6 changes: 3 additions & 3 deletions src/erlkaf_producer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ handle_info({stats, Stats0}, #state{stats_cb = StatsCb, client_id = ClientId} =
{noreply, State#state{stats = Stats}};

handle_info({oauthbearer_token_refresh, OauthBearerConfig}, #state{
oauthbearer_token_refresh_cb = OauthbearerTokenRefreshCb,
client_id = ClientId,
oauthbearer_token_refresh_cb = OauthbearerTokenRefreshCb,
client_id = ClientId,
ref = ClientRef} = State) ->

case catch erlkaf_utils:call_oauthbearer_token_refresh_callback(OauthbearerTokenRefreshCb, OauthBearerConfig) of
{ok, Token, LifeTime, Principal} ->
erlkaf_nif:producer_oauthbearer_set_token(ClientRef, Token, LifeTime, Principal, "");
Expand Down

0 comments on commit ac3f3c7

Please sign in to comment.