From 902b3992d102a9ea200c8198be5946140ce34509 Mon Sep 17 00:00:00 2001 From: singingbush Date: Sat, 14 Jan 2023 17:41:13 +0000 Subject: [PATCH 1/2] Add Github Action for CI, fix for recent D and vibe-core, ensure build supports D 2.087.0 (released 2019) and above versions --- .gitignore | 12 ++++++++++++ Readme.md | 3 ++- dub.json | 9 ++++++++- examples/consumer/dub.json | 3 +-- examples/consumer/dub.selections.json | 19 ------------------- examples/consumer/source/app.d | 9 ++++++--- examples/httplog/dub.json | 3 ++- examples/httplog/source/app.d | 19 +++++++++++++------ examples/producer/dub.json | 3 +-- examples/producer/dub.selections.json | 19 ------------------- examples/producer/source/app.d | 10 +++++++--- 11 files changed, 52 insertions(+), 57 deletions(-) delete mode 100644 examples/consumer/dub.selections.json delete mode 100644 examples/producer/dub.selections.json diff --git a/.gitignore b/.gitignore index 60de9bb..6c85cbf 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,21 @@ __dummy.html *.userprefs *.a dub.selections.json + +# Ignore SublimeText specific files +*.sublime-workspace kafka-d.sublime-project examples/consumer/consumer.sublime-project examples/producer/producer.sublime-project + +# Ignore Visual Studio code specific files +launch.json +settings.json +*.userprefs + +# Ignore built artifacts __test__library__ +*-test-library examples/consumer/consumer +examples/httplog/httplog examples/producer/producer \ No newline at end of file diff --git a/Readme.md b/Readme.md index 7604e15..8046e33 100644 --- a/Readme.md +++ b/Readme.md @@ -1,5 +1,6 @@ -Kafka-d is a D Kafka client that depends on the vibe.d framework. +Kafka-d is a D Kafka client that depends on the vibe-core. +[![DUB Package](https://img.shields.io/dub/v/kafka-d.svg)](https://code.dlang.org/packages/kafka-d) [![Build Status](https://travis-ci.org/tamediadigital/kafka-d.svg?branch=master)](https://travis-ci.org/tamediadigital/kafka-d) #### Usage diff --git a/dub.json b/dub.json index 79471d6..cf7e0c7 100644 --- a/dub.json +++ b/dub.json @@ -5,7 +5,14 @@ "authors": ["Piotr Szturmaj", "Yannick Koechlin"], "license" : "MIT", "dependencies": { - "vibe-d": ">=0.8.4" + "vibe-core": ">=1.16.0" + }, + "buildRequirements": [ + "allowWarnings" + ], + "toolchainRequirements": { + "dub": ">=1.14.0", + "frontend": ">=2.087" }, "libs": ["snappy"], "targetType": "library" diff --git a/examples/consumer/dub.json b/examples/consumer/dub.json index fe49c38..87ca909 100644 --- a/examples/consumer/dub.json +++ b/examples/consumer/dub.json @@ -5,6 +5,5 @@ "authors": [ "Piotr Szturmaj" ], "dependencies": { "kafka-d": {"version": "~master", "path": "../../"} - }, - "dflags" : ["-version=VibeUseOpenSSL11"] + } } diff --git a/examples/consumer/dub.selections.json b/examples/consumer/dub.selections.json deleted file mode 100644 index d7e69f0..0000000 --- a/examples/consumer/dub.selections.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "fileVersion": 1, - "versions": { - "botan": "1.12.10", - "botan-math": "1.0.3", - "diet-ng": "1.5.0", - "eventcore": "0.8.35", - "kafka-d": {"path":"../../"}, - "libasync": "0.8.3", - "libevent": "2.0.2+2.0.16", - "memutils": "0.4.11", - "mir-linux-kernel": "1.0.0", - "openssl": "1.1.6+1.0.1g", - "stdx-allocator": "2.77.2", - "taggedalgebraic": "0.10.11", - "vibe-core": "1.4.1", - "vibe-d": "0.8.4" - } -} diff --git a/examples/consumer/source/app.d b/examples/consumer/source/app.d index 8895b31..9060b41 100644 --- a/examples/consumer/source/app.d +++ b/examples/consumer/source/app.d @@ -1,6 +1,9 @@ -import std.stdio; -import vibe.vibe; -import kafkad.client; +import std.stdio : writefln; + +import vibe.core.core : runTask, runEventLoop, runWorkerTask; +import vibe.core.log : setLogLevel, LogLevel; + +import kafkad.client : BrokerAddress, Client, Configuration, Consumer, Offsets; void main() { runTask({ diff --git a/examples/httplog/dub.json b/examples/httplog/dub.json index de92cb6..cc7b692 100644 --- a/examples/httplog/dub.json +++ b/examples/httplog/dub.json @@ -4,7 +4,8 @@ "authors": [ "Piotr Szturmaj" ], "dependencies": { "kafka-d": {"version": "~master", "path": "../../"}, - "vibe-d": "~>0.7.25" + "vibe-core": ">=1.16.0", + "vibe-d:web": ">=0.9.0" }, "versions": ["VibeDefaultMain"] } \ No newline at end of file diff --git a/examples/httplog/source/app.d b/examples/httplog/source/app.d index 89db97b..f2e73d5 100644 --- a/examples/httplog/source/app.d +++ b/examples/httplog/source/app.d @@ -1,6 +1,12 @@ import std.stdio; -import vibe.vibe; -import kafkad.client; +import std.concurrency : Tid, setMaxMailboxSize, MailboxFull, OnCrowding, send, receive; + +import vibe.core.core : runTask; +import vibe.core.task : Task; +import vibe.core.log : setLogLevel, logInfo, LogLevel; +import vibe.http.server : listenHTTP, HTTPServerRequest, HTTPServerResponse, HTTPServerSettings; + +import kafkad.client : BrokerAddress, Client, Configuration, Producer; shared static this() { @@ -11,7 +17,7 @@ shared static this() listenHTTP(settings, &handleRequest); - producerTid = runTask({ + Task task = runTask({ Configuration config; // adjust config's properties if necessary config.metadataRefreshRetryCount = 0; @@ -30,13 +36,14 @@ shared static this() } }); + producerTid = task.tid(); + setMaxMailboxSize(producerTid, 100, OnCrowding.throwException); } -shared Tid producerTid; +Tid producerTid; -void handleRequest(HTTPServerRequest req, - HTTPServerResponse res) +void handleRequest(HTTPServerRequest req, HTTPServerResponse res) { if (req.path == "/") res.writeBody("Hello, World!", "text/plain"); diff --git a/examples/producer/dub.json b/examples/producer/dub.json index 689a2e7..9b041ce 100644 --- a/examples/producer/dub.json +++ b/examples/producer/dub.json @@ -4,6 +4,5 @@ "authors": [ "Piotr Szturmaj" ], "dependencies": { "kafka-d": {"version": "~master", "path": "../../"} - }, - "dflags" : ["-version=VibeUseOpenSSL11"] + } } diff --git a/examples/producer/dub.selections.json b/examples/producer/dub.selections.json deleted file mode 100644 index d7e69f0..0000000 --- a/examples/producer/dub.selections.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "fileVersion": 1, - "versions": { - "botan": "1.12.10", - "botan-math": "1.0.3", - "diet-ng": "1.5.0", - "eventcore": "0.8.35", - "kafka-d": {"path":"../../"}, - "libasync": "0.8.3", - "libevent": "2.0.2+2.0.16", - "memutils": "0.4.11", - "mir-linux-kernel": "1.0.0", - "openssl": "1.1.6+1.0.1g", - "stdx-allocator": "2.77.2", - "taggedalgebraic": "0.10.11", - "vibe-core": "1.4.1", - "vibe-d": "0.8.4" - } -} diff --git a/examples/producer/source/app.d b/examples/producer/source/app.d index 4940e4d..647d5bc 100644 --- a/examples/producer/source/app.d +++ b/examples/producer/source/app.d @@ -1,6 +1,10 @@ -import std.stdio; -import vibe.vibe; -import kafkad.client; +import std.stdio : writeln, writefln; +import core.time : msecs; + +import vibe.core.core : runTask, runEventLoop, runWorkerTask, sleep; +import vibe.core.log : setLogLevel, LogLevel; + +import kafkad.client : BrokerAddress, Client, Configuration, Producer; void main() { runTask({ From d48dbd11be57d31a5bb00400bea027162b09a57a Mon Sep 17 00:00:00 2001 From: singingbush Date: Sat, 14 Jan 2023 18:15:41 +0000 Subject: [PATCH 2/2] set 2.090.1 to min supported D version --- .github/workflows/dub.yml | 107 ++++++++++++++++++++++++++++++++++++++ dub.json | 2 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dub.yml diff --git a/.github/workflows/dub.yml b/.github/workflows/dub.yml new file mode 100644 index 0000000..c7e188e --- /dev/null +++ b/.github/workflows/dub.yml @@ -0,0 +1,107 @@ +name: dub + +on: + schedule: + - cron: '30 2 2 * *' + push: + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + name: ${{ matrix.compiler }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest ] + compiler: + - dmd-latest + - ldc-latest + - dmd-2.101.2 + - dmd-2.100.2 + - dmd-2.099.1 + - ldc-1.29.0 # eq to dmd v2.099.1 + include: + - { os: ubuntu-latest, compiler: dmd-2.098.1 } # 2021 December + - { os: ubuntu-latest, compiler: dmd-2.097.2 } # 2021 + - { os: ubuntu-latest, compiler: dmd-2.095.1 } # 2021 + - { os: ubuntu-latest, compiler: dmd-2.090.1 } # 2020 Feb + - { os: ubuntu-latest, compiler: ldc-1.28.1 } + + steps: + - uses: actions/checkout@v3 + + - name: Install D ${{ matrix.compiler }} + uses: dlang-community/setup-dlang@v1 + with: + compiler: ${{ matrix.compiler }} + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.os, 'ubuntu') + run: sudo apt-get update && sudo apt-get install libsnappy-dev -y + + - name: Install dependencies on Mac OSX + if: startsWith(matrix.os, 'macos') + run: brew install snappy + + - name: 'dub build' + run: dub build --compiler=$DC + + - name: 'dub test' + run: dub test --compiler=$DC + + - name: Build the Consumer Example + working-directory: ./examples/consumer + run: dub build + + - name: Build the HTTP Log Example + working-directory: ./examples/httplog + run: dub build + + - name: Build the Producer Example + working-directory: ./examples/producer + run: dub build + +# +# On Ubuntu we can use GDC. The compatibility of gdc is: +# gcc gdc-10 -> 2.076 (default on Ubuntu 20.04) +# gcc gdc-11 -> 2.076 +# gcc gdc-12 -> 2.100 +# Unfortunately gdc builds are blocked by https://github.com/D-Programming-Deimos/openssl/issues/94 +# +# gdc-latest: +# name: ${{ matrix.compiler }} on ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# os: [ ubuntu-22.04 ] +# compiler: [ gdc-10, gdc-11, gdc-12 ] +# runs-on: ${{ matrix.os }} +# steps: +# - uses: actions/checkout@v3 +# +# - name: Install DMD (so dub is available) +# uses: dlang-community/setup-dlang@v1 +# with: +# compiler: dmd-latest +# +# - name: Install ${{ matrix.compiler }} +# run: | +# sudo apt-get update +# sudo apt-get install ${{ matrix.compiler }} -y +# sudo apt-get install libsnappy-dev -y +# +# - name: Show version +# run: | +# ${{ matrix.compiler }} --version +# dub --version +# +# - name: Build with release profile +# env: +# DC: ${{ matrix.compiler }} +# run: dub build --compiler=${{ matrix.compiler }} diff --git a/dub.json b/dub.json index cf7e0c7..590eb87 100644 --- a/dub.json +++ b/dub.json @@ -12,7 +12,7 @@ ], "toolchainRequirements": { "dub": ">=1.14.0", - "frontend": ">=2.087" + "frontend": ">=2.090" }, "libs": ["snappy"], "targetType": "library"