Skip to content

Commit

Permalink
Client version 6.1.7 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
idantavor committed Aug 3, 2023
1 parent 43c752c commit 4a530aa
Show file tree
Hide file tree
Showing 17 changed files with 451 additions and 255 deletions.
44 changes: 1 addition & 43 deletions .github/workflows/build_test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,7 @@ jobs:

test:
needs: build
runs-on: ubuntu-22.04
timeout-minutes: 5
services:
aerospike-test:
image: aerospike:4.9.0.11
ports:
- 3000:3000
- 3001:3001
- 3002:3002
- 3003:3003
env:
AEROSPIKE_HOST: localhost
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit and integration tests
run: lein eftest :all

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results
path: |
target/junit.xml
uses: ./.github/workflows/test.yml

event_file:
needs: test
Expand Down
36 changes: 1 addition & 35 deletions .github/workflows/ci_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,7 @@ jobs:

test:
needs: build
runs-on: ubuntu-22.04
timeout-minutes: 5
services:
aerospike-test:
image: aerospike:4.9.0.11
ports:
- 3000:3000
- 3001:3001
- 3002:3002
- 3003:3003
env:
AEROSPIKE_HOST: localhost
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit and Integration tests
run: lein eftest :all
uses: ./.github/workflows/test.yml

deploy:
needs: test
Expand Down
36 changes: 1 addition & 35 deletions .github/workflows/ci_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,7 @@ jobs:

test:
needs: build
runs-on: ubuntu-22.04
timeout-minutes: 5
services:
aerospike-test:
image: aerospike:4.9.0.11
ports:
- 3000:3000
- 3001:3001
- 3002:3002
- 3003:3003
env:
AEROSPIKE_HOST: localhost
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit and Integration tests
run: lein eftest :all
uses: ./.github/workflows/test.yml

deploy:
needs: test
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on: [workflow_call]

jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit and Integration tests
run: lein eftest :all
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
## This library follows [Semantic Versioning](https://semver.org).
## This CHANGELOG follows [keepachangelog](https://keepachangelog.com/en/1.0.0/).

### VERSION [3.0.0]: https://github.com/AppsFlyer/aerospike-clj/pull/62
#### Changed
* use aerospike client version 6.1.10
* use test containers for integration tests

#### Added
* batch operate support
* completion executor support (with default)
* client-events additional context support

#### Removed
* empty test namespace

### VERSION 2.0.7
#### Changed
* Fixed a bug with reporting metrics for `AerospikeSingleIndexBatchOps/operate`.
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ An opinionated Clojure library wrapping Aerospike Java Client.
# Requirements
- Java 8
- Clojure 1.8
- Aerospike server version >= `4.9.0`
- Clojure version >= `1.11.0`

# Features
- Converts Java client's callback model into Java(8) `CompletableFuture` based API.
Expand Down Expand Up @@ -53,20 +55,20 @@ user=> (def c (aero/init-simple-aerospike-client
```

It is possible to inject additional asynchronous user-defined behaviour. To do that add an implementation of the
`ClientEvents` protocol.
`ClientEvents` protocol during client initialization or per operation.
Some useful info is passed in-order to support metering and to read client configuration. `op-start-time` is
`(System/nanoTime)`, see more [here](https://appsflyer.github.io/aerospike-clj/advanced-async-hooks.html).
`(System/nanoTime)`.
see more [here](https://appsflyer.github.io/aerospike-clj/advanced-async-hooks.html).

```clojure
(let [c (aero/init-simple-aerospike-client
["localhost"]
"test"
{:client-events (reify ClientEvents
(on-success [_ op-name op-result index op-start-time db]
(when (:enable-logging? db)
(on-success [_ op-name op-result index op-start-time]
(println op-name "success!")))
(on-failure [_ op-name op-ex index op-start-time db]
(println "oh-no" op-name "failed on index" index)))})]
(on-failure [_ op-name op-ex index op-start-time]
(println "oh-no" op-name "failed on index" index)))})]

(get-single c "index" "set-name"))
; for better performance, a `deftype` might be preferred over `reify`, if possible.
Expand Down Expand Up @@ -114,12 +116,7 @@ Call `expiry-unix` with the returned TTL to get a TTL relative to the UNIX epoch
Executed via running `lein test`.

### Integration tests
Testing is performed against a local Aerospike instance. You can also run an instance inside a docker container:

```shell
$ sudo docker run -d --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike
$ lein test :integration
```
Testing is performed against a local Aerospike docker container.

#### Mocking in application unit tests
For unit tests purposes you can use a mock client that implements the client protocols: `MockClient`.
Expand Down
8 changes: 5 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.appsflyer/aerospike-clj "2.0.8-SNAPSHOT"
(defproject com.appsflyer/aerospike-clj "3.0.0-SNAPSHOT"
:description "An Aerospike Clojure client."
:url "https://github.com/AppsFlyer/aerospike-clj"
:license {:name "Eclipse Public License"
Expand All @@ -14,12 +14,14 @@
:password :env/clojars_password
:sign-releases false}]]
:dependencies [[org.clojure/tools.logging "1.2.4"]
[com.aerospike/aerospike-client "4.4.15"]
[com.aerospike/aerospike-client "6.1.10"]
[funcool/promesa "8.0.450"]]
:profiles {:dev {:plugins [[lein-eftest "0.5.9"]]
:dependencies [[org.clojure/clojure "1.11.1"]
[clj-test-containers "0.7.4"]
[criterium "0.4.6"]
[cheshire "5.11.0"]
[tortue/spy "2.14.0"]
[com.fasterxml.jackson.core/jackson-databind "2.11.2"]
[clj-kondo "2022.04.25"]]
:eftest {:multithread? false
Expand All @@ -31,7 +33,7 @@
:test-selectors {:integration :integration
:all (constantly true)
:default (complement :integration)}}
:docs {:plugins [[lein-codox "0.10.7"]]
:docs {:plugins [[lein-codox "0.10.8"]]
:codox {:output-path "codox"
:source-uri "http://github.com/AppsFlyer/aerospike-clj/blob/{version}/{filepath}#L{line}"
:metadata {:doc/format :markdown}}}})
7 changes: 4 additions & 3 deletions src/main/clojure/aerospike_clj/aerospike_record.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

(defn record->map [^Record record]
(and record
(let [bins ^Map (.bins record)
payload (if (single-bin? bins)
(let [bins ^Map (.bins record)
payload (when (some? bins)
(if (single-bin? bins)
;; single bin record
(utils/desanitize-bin-value (.get bins ""))
;; multiple-bin record
(reduce-kv (fn [m k v]
(assoc m k (utils/desanitize-bin-value v)))
{}
bins))]
bins)))]
(->AerospikeRecord
payload
^Integer (.generation ^Record record)
Expand Down

0 comments on commit 4a530aa

Please sign in to comment.