Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADDED: C support + C pull consumer example #197

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist
node_modules
html
.idea/
.vscode/
**/node/node_modules/
**/node/package.json
**/node/package-lock.json
1 change: 1 addition & 0 deletions cmd/nbe/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (r *ImageBuilder) Run() (string, error) {
c := exec.Command(
"docker",
"build",
// "--progress=plain", // Use plain output for debuggig
levb marked this conversation as resolved.
Show resolved Hide resolved
"--tag", imageTag,
buildDir,
)
Expand Down
1 change: 1 addition & 0 deletions cmd/nbe/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var (
DotNet: "Main.cs",
DotNet2: "Main.cs",
Elixir: "main.exs",
C: "main.c",
}

languageMultiCommentDelims = map[string][2]string{
Expand Down
23 changes: 23 additions & 0 deletions docker/c/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:latest AS build

WORKDIR /opt/app

RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y cmake
RUN apt-get install -y curl
RUN apt-get install -y git
RUN apt-get install -y golang
RUN apt-get install -y jq
RUN apt-get install -y libprotobuf-c-dev
RUN apt-get install -y libsodium-dev
RUN apt-get install -y libssl-dev
RUN apt-get install -y wget

COPY install-nats-c.sh .
RUN bash install-nats-c.sh

COPY . ./
RUN mkdir build && cd build && cmake .. && make

CMD ["/opt/app/build/app"]
15 changes: 15 additions & 0 deletions docker/c/install-nats-c.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rel=$(curl -s https://api.github.com/repos/nats-io/nats.c/releases/latest | jq -r '.tag_name')
wget https://github.com/nats-io/nats.c/archive/refs/tags/${rel}.tar.gz
tar -xzf ${rel}.tar.gz
cd nats.c-${rel#v}
mkdir build
cd build
cmake \
-DNATS_BUILD_TLS_USE_OPENSSL_1_1_API=ON \
-DNATS_BUILD_STREAMING=OFF \
-DNATS_BUILD_EXAMPLES=OFF \
..
make
make install


8 changes: 8 additions & 0 deletions examples/jetstream/pull-consumer/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.28)

set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "/usr/local/lib")

file(GLOB SOURCES "*.c")
add_executable(app ${SOURCES})
target_link_libraries(app nats)
Loading
Loading