Skip to content

chore: add a pure C worker example#174

Draft
jfonseca-aneo wants to merge 1 commit into
mainfrom
jf/c-worker
Draft

chore: add a pure C worker example#174
jfonseca-aneo wants to merge 1 commit into
mainfrom
jf/c-worker

Conversation

@jfonseca-aneo
Copy link
Copy Markdown
Contributor

@jfonseca-aneo jfonseca-aneo commented Apr 27, 2026

Motivation

The ArmoniK C++ SDK already provides a worker wrapper in C++. This adds a sample showing how to write a worker usingthe lower-level C ABI (ArmoniKSDKInterface.h) directly, without the C++ SDK worker wrapper. This is useful for users who want to implement workers in pure C or in any language that can expose a C-compatible shared library.

Description

Adds a new cpp/HelloWorldC sample. The worker is a pure C shared library that implements the five armonik_*
functions from ArmoniKSDKInterface.h:

  • armonik_create_service / armonik_destroy_service
  • armonik_enter_session / armonik_leave_session
  • armonik_call — dispatches on function_name to demonstrate three behaviors:
    • hello: appends " World!" to the payload and returns ARMONIK_STATUS_OK
    • error: returns ARMONIK_STATUS_ERROR (permanent task failure, no retry)
    • retry: returns ARMONIK_STATUS_RETRY (transient failure, ArmoniK reschedules up to max_retries)

The client is written in C++ using the existing ArmoniK C++ SDK and selects the behavior via --error / --retry
CLI flags.

Testing

Tested end-to-end against a local ArmoniK deployment with a cppdynamic partition:

  • Normal mode (hello): task completes successfully, result is "Hello, World!".
  • Error mode (--error): task fails permanently with TASK_STATUS_ERROR: Permanent error requested by client.
  • Retry mode (--retry): task is retried three times (max_retries=3) then fails with the transient error
    message.

Expected outputs for all three modes are documented in the README.

Impact

  • Adds a new standalone sample; no existing samples are modified.
  • No new runtime dependencies: the C worker links only against libc at runtime — ArmoniKSDKInterface.h is the only compile-time dependency.
  • No CI changes required (the existing C++ pipeline covers this sample).

Additional Information

  • The worker .so filename must not include an SDK version suffix (unlike C++ SDK workers), because the dynamic
    worker loads it by the exact name passed in TaskOptions.

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • I have thoroughly tested my modifications and added tests when necessary.
  • Tests pass locally and in the CI.
  • I have assessed the performance impact of my modifications.

Comment on lines +25 to +27
# Clone and build the SDK from the feature branch (introduces ARMONIK_STATUS_RETRY)
ARG SDK_BRANCH=jf/retryExcep
RUN git clone --branch "${SDK_BRANCH}" --depth 1 \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: change it when release is available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants