Skip to content

Commit

Permalink
Merge pull request #3 from JesseStimpson/fmt
Browse files Browse the repository at this point in the history
fmt
  • Loading branch information
JesseStimpson authored Feb 17, 2024
2 parents 80ab87f + 7d04af9 commit 86f3538
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 28 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ permissions:
contents: read

jobs:
fmt:
runs-on: ubuntu-20.04
name: fmt / OTP ${{matrix.otp}}
strategy:
matrix:
otp: ['25']
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
- name: Checking code formatting
run: rebar3 fmt --check
eunit:
runs-on: ubuntu-20.04
name: eunit / OTP ${{matrix.otp}} / FDB ${{matrix.fdb}}
Expand Down
11 changes: 0 additions & 11 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Building
Assuming you have installed the FoundationDB C API library, building erlfdb
is as simple as:

$ make
$ rebar3 compile

Alternatively, adding erlfdb as a rebar dependency should Just Work ®.

Expand Down
7 changes: 7 additions & 0 deletions erlfdb_cluster_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/usr/local/libexec/fdbserver \
-i JMS \
-p 127.0.0.1:55400 \
-C "/Users/jstimpson/dev/JesseStimpson.couchdb-erlfdb/.erlfdb/erlfdb.cluster" \
-d "/Users/jstimpson/dev/JesseStimpson.couchdb-erlfdb/.erlfdb" \
-L "/Users/jstimpson/dev/JesseStimpson.couchdb-erlfdb/.erlfdb" \
--knob-disable_posix_kernel_aio=1
2 changes: 2 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
erlfmt
]}.

{erlfmt, [write]}.

{provider_hooks, [
{pre, [
{compile, {pc, compile}},
Expand Down
16 changes: 10 additions & 6 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
MaxAPIVersion =
begin
VsnInfo = os:cmd("fdbcli --version"),
{match, [ProtocolStr]} = re:run(VsnInfo, "protocol ([a-f0-9]*)", [{capture, [1], list}]),
ProtocolVsn = list_to_integer(ProtocolStr, 16),
APIVersionBytes = (ProtocolVsn band 16#0000000FFF00000) bsr 20,
integer_to_list(APIVersionBytes, 16)
case re:run(VsnInfo, "protocol ([a-f0-9]*)", [{capture, [1], list}]) of
{match, [ProtocolStr]} ->
ProtocolVsn = list_to_integer(ProtocolStr, 16),
APIVersionBytes = (ProtocolVsn band 16#0000000FFF00000) bsr 20,
integer_to_list(APIVersionBytes, 16);
nomatch ->
undefined
end
end.

% https://github.com/markusn/coveralls-erl#example-usage-rebar3-and-github-actions
Expand All @@ -33,12 +37,12 @@ CoverallConfig =
{
"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
"CFLAGS",
"$CFLAGS -I/usr/local/include -Ic_src/ -g -Wall -Werror -DFDB_API_VERSION=" ++ MaxAPIVersion
"$CFLAGS -I/usr/local/include -Ic_src/ -g -Wall -Werror " ++ (case MaxAPIVersion of undefined -> ""; _ -> "-DFDB_API_VERSION=" ++ MaxAPIVersion end)
},
{
"win32",
"CFLAGS",
"$CFLAGS /I\"c:/Program Files/foundationdb/include\" /O2 /DNDEBUG /DFDB_API_VERSION=" ++ MaxAPIVersion
"$CFLAGS /I\"c:/Program Files/foundationdb/include\" /O2 /DNDEBUG " ++ (case MaxAPIVersion of undefined -> ""; _ -> "/DFDB_API_VERSION=" ++ MaxAPIVersion end)
},

{
Expand Down
8 changes: 6 additions & 2 deletions src/erlfdb_tenant_management.erl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
-module(erlfdb_tenant_management).

-export([transactional/2, list_tenants/1, list_tenants/4, get_tenant/2, create_tenant/2, delete_tenant/2]).
-export([
transactional/2, list_tenants/1, list_tenants/4, get_tenant/2, create_tenant/2, delete_tenant/2
]).

-define(TENANT_MAP(TenantName), iolist_to_binary([<<16#FF, 16#FF, "/management/tenant/map/">>, TenantName])).
-define(TENANT_MAP(TenantName),
iolist_to_binary([<<16#FF, 16#FF, "/management/tenant/map/">>, TenantName])
).

-define(IS_DB, {erlfdb_database, _}).
-define(IS_TX, {erlfdb_transaction, _}).
Expand Down
18 changes: 10 additions & 8 deletions src/erlfdb_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ create_and_open_tenant(Db, Options, TenantName) ->
_ ->
ok
end,
erlfdb_tenant_management:transactional(Db,
erlfdb_tenant_management:transactional(
Db,
fun(Tx) ->
case erlfdb:wait(erlfdb_tenant_management:get_tenant(Tx, TenantName)) of
not_found ->
erlfdb_tenant_management:create_tenant(Tx, TenantName);
_ ->
ok
end
end),
case erlfdb:wait(erlfdb_tenant_management:get_tenant(Tx, TenantName)) of
not_found ->
erlfdb_tenant_management:create_tenant(Tx, TenantName);
_ ->
ok
end
end
),
erlfdb:open_tenant(Db, TenantName).

clear_and_delete_test_tenant(Db) ->
Expand Down

0 comments on commit 86f3538

Please sign in to comment.