Doxygen generated C++ documentation

class AdditionService : private ArmoniK::Sdk::Worker::ServiceBase
#include <AdditionService.h>

Example implementation of a ArmoniK::Sdk::Worker::ServiceBase.

Public Functions

inline virtual void *enter_session(const char *session_id) override

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx) override

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

inline virtual std::string call(void*, const std::string &name, const std::string &input) override

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

inline int32_t add_ints(int32_t a, int32_t b)

Adds 2 ints.

Parameters:
  • a – A

  • b – B

Returns:

A+B

inline float add_floats(float a, float b)

Add 2 floats.

Parameters:
  • a – A

  • b – B

Returns:

A+B

Private Functions

virtual std::string call(void *session_ctx, const std::string &name, const std::map<std::string, std::string> &inputs)

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

struct AppId
#include <ContextIds.h>

Id of an application.

Public Functions

inline bool operator==(const AppId &other) const

Equality operator.

Parameters:

other – Other AppId

Returns:

true if the AppIds’ fields are equal

inline bool operator!=(const AppId &other) const

Inequality operator.

Parameters:

other – Other AppId

Returns:

false if the AppIds’ fields are equal

inline bool empty() const

Checks if the AppId is empty.

Returns:

True if the application name is empty

inline void clear()

Clears the application name and version.

Public Members

std::string application_name

Application’s name.

std::string application_version

Application’s version.

Note

Can be empty

class ApplicationManager

Application manager to load and unload applications.

Public Functions

explicit ApplicationManager(const ArmoniK::Sdk::Common::Configuration &config, const armonik::api::common::logger::Logger &logger)

Creates an application manager.

Parameters:

config – Configuration

ApplicationManager &UseApplication(const AppId &appId) &

Configures the application manager to use the given application.

Note

If the appId is different to the current one, the currently loaded service will be destroyed and the application will be unloaded before loading the new one

Note

If the appId is identical to the current one, this call does nothing

Parameters:

appId – Application Id

Returns:

this ApplicationHandler

ApplicationManager &UseLibrary(const ArmoniK::Sdk::Common::DynamicLibrary &lib, const std::string &service_namespace = "", const std::string &service_name = "") &

Configures the application manager to load a library directly by path (convention mode). The library is loaded from lib.library_path; ABI symbols are always resolved with the “armonik_” prefix. lib.symbol carries the method name passed to armonik_call at execution time.

Note

Caches by library_path + service_name; a repeated call with the same values is a no-op.

Parameters:
  • lib – DynamicLibrary descriptor

  • service_namespace – Namespace passed to armonik_create_service (empty for single-service workers)

  • service_name – Name passed to armonik_create_service (empty for single-service workers)

Returns:

this ApplicationManager

ApplicationManager &UseService(const ServiceId &serviceId) &

Configures the application manager to use the given service.

Note

If the current service matches the requested service id, then this does nothing

Note

If the current service is different from the requested service, then this will destroy the current service before creating the new one

Parameters:

serviceId – Service id

Returns:

this Application manager

ApplicationManager &UseSession(const std::string &sessionId) &

Configures the applcation manager to use the given session.

Parameters:

sessionId – Session id

Returns:

this Application manager

armonik::api::worker::ProcessStatus Execute(armonik::api::worker::TaskHandler &taskHandler, const std::string &method_name, const std::string &method_arguments)

Executes the task given by the task handler.

Parameters:
  • taskHandler – Task handler

  • method_name – Name of the method to execute

  • method_arguments – Serialized arguments of the method

Returns:

ProcessStatus telling whether the call was successful or not

armonik::api::worker::ProcessStatus Execute(armonik::api::worker::TaskHandler &taskHandler, const std::string &method_name, const std::map<std::string, std::string> &inputs, const std::map<std::string, std::string> &outputs)

Executes the task given by the task handler using named blob maps (convention mode). Serializes inputs and outputs to JSON and delegates to Execute(taskHandler, method_name, json).

Parameters:
  • taskHandler – Task handler

  • method_name – Name of the method to execute

  • inputs – Named input blob IDs

  • outputs – Named output blob IDs

Returns:

ProcessStatus telling whether the call was successful or not

Private Members

ArmoniKFunctionPointers functionPointers

Loaded application’s function pointers.

AppId currentId

Currently loaded application id.

ServiceManager service_manager

Current service manager.

DynamicLib currentLibrary

Currently loaded library.

std::string applicationsBasePath

Base path in which to look for the library to load (legacy mode)

std::string currentLibraryPath

Path of the currently loaded library (convention mode); empty when in legacy mode.

std::string currentLibraryServiceName

Service name used when the current library was loaded (convention mode)

armonik::api::common::logger::LocalLogger logger

Local Logger.

struct ArmoniKFunctionPointers
#include <ContextIds.h>

Structure containing the dynamic library’s function pointers to the ArmoniK SDK Interface .

Public Functions

inline void clear()

Clears the function pointers.

Public Members

armonik_create_service_t create_service

Function to create a service. See armonik_create_service()

armonik_destroy_service_t destroy_service

Function to destroy a service. See armonik_destroy_service()

armonik_enter_session_t enter_session

Function to enter a session. See armonik_enter_session()

armonik_leave_session_t leave_session

Function to leave a session. See armonik_leave_session()

armonik_call_t call

Function to call a method. See armonik_call()

class ArmoniKSdkException : public std::runtime_error

ArmoniK SDK exception.

Public Functions

inline explicit ArmoniKSdkException(const char *message)

Creates an ArmoniKSdkException.

Parameters:

message – error message

inline explicit ArmoniKSdkException(const std::string &message)

Creates an ArmoniKSdkException.

Parameters:

message – error message

class ArmoniKWorker

Subclassed by ArmoniK::Sdk::DynamicWorker::DynamicWorker

struct BlobDefinition
#include <BlobDefinition.h>

Represents an input blob: either raw data to be uploaded, or a reference to an already-existing blob by ID.

Use BlobDefinition::FromData() when you have the raw bytes and want the library to upload them. Use BlobDefinition::FromBlobId() to reference a blob that was already uploaded (e.g. a shared large dataset reused across many tasks).

Public Functions

inline bool IsRawData() const

Returns true if this definition holds raw data (to be uploaded), false if it references an existing blob ID.

inline const std::string &GetData() const

Returns the raw data. Only valid when IsRawData() is true.

inline const std::string &GetBlobId() const

Returns the blob ID. Only valid when IsRawData() is false.

Public Static Functions

static inline BlobDefinition FromData(std::string data)

Creates a BlobDefinition carrying raw data to be uploaded on submission.

Parameters:

data – Raw bytes to upload

static inline BlobDefinition FromBlobId(std::string blob_id)

Creates a BlobDefinition referencing an already-uploaded blob by its result ID.

Parameters:

blob_id – Result ID of the existing blob

Private Members

bool is_raw_data_ = true
std::string value_
class ComputePlane
#include <Configuration.h>

Compute plane connectivity configuration.

Public Functions

ComputePlane(const Configuration &configuration)

Constructs a ComputePlane object with the given configuration.

Parameters:

configuration – The Configuration object containing address information.

ComputePlane(const ComputePlane &other)

Copy constructor.

Parameters:

other – Other compute plane

ComputePlane(ComputePlane &&other) noexcept

Move constructor.

Parameters:

other – Other compute plane

ComputePlane &operator=(const ComputePlane &other)

Copy assignment operator.

Parameters:

other – Other compute plane

Returns:

this

ComputePlane &operator=(ComputePlane &&other) noexcept

Move assignment operator.

Parameters:

other – Other compute plane

Returns:

this

~ComputePlane()

Destroy the ComputePlane object.

absl::string_view get_server_address() const

Returns the server address.

Returns:

A reference to the server address string.

void set_worker_address(std::string socket_address)

Sets the worker address with the given socket address.

Parameters:

socket_address – The socket address to set for the worker.

void set_agent_address(std::string agent_address)

Sets the agent address with the given agent address.

Parameters:

agent_address – The agent address to set for the agent.

absl::string_view get_agent_address() const

Returns the agent address.

Returns:

A reference to the agent address string.

Private Functions

const armonik::api::common::options::ComputePlane &get_impl() const
armonik::api::common::options::ComputePlane &set_impl()

Private Members

std::unique_ptr<armonik::api::common::options::ComputePlane> impl
class Configuration
#include <Configuration.h>

Configuration.

Public Functions

Configuration()

Default constructor.

~Configuration()
Configuration(const Configuration &other)

Copy constructor.

Parameters:

other – Other configuration

Configuration(Configuration &&other) noexcept

Move constructor.

Parameters:

other – Other configuration

Configuration &operator=(const Configuration &other)

Copy assignment operator.

Parameters:

other – Other configuration

Returns:

this

Configuration &operator=(Configuration &&other) noexcept

Move assignment operator.

Parameters:

other – Other configuration

Returns:

this

std::string get(const std::string &string) const

Get the value associated with the given key.

Parameters:

string – Key to look up.

Returns:

The value associated with the key, as a string.

void set(const std::string &string, const std::string &value)

Set the value associated with the given key.

Parameters:
  • string – Key to set the value for.

  • value – Value to set for the key.

const std::map<std::string, std::string> &list() const

List defined values of this configuration.

Note

Does not include environment variables

Returns:

Map representation of this configuration

Configuration &add_json_configuration(absl::string_view file_path)

Add JSON configuration from a file.

Parameters:

file_path – Path to the JSON file.

Returns:

Reference to the current Configuration object.

Configuration &add_env_configuration()

Add environment variable configuration.

Returns:

Reference to the current Configuration object.

ComputePlane get_compute_plane() const

Get the current ComputePlane configuration.

Returns:

A ComputePlane object representing the current configuration.

ControlPlane get_control_plane() const

Get the current ControlPlane configuration.

Returns:

A ControlPlane object

armonik::api::common::logger::Level get_log_level() const

Get the configured log level.

Returns:

Log level

explicit operator armonik::api::common::utils::Configuration()

Casts this configuration to its Api equivalent.

Returns:

Api Configuration equivalent to this

Private Functions

const armonik::api::common::utils::Configuration &get_impl() const
armonik::api::common::utils::Configuration &set_impl()

Private Members

std::unique_ptr<armonik::api::common::utils::Configuration> impl

Friends

friend class ComputePlane
friend class ControlPlane
class ControlPlane
#include <Configuration.h>

Control plane connectivity configuration.

Public Functions

ControlPlane(const Configuration &config)

Constructs a ControlPlane object with the given configuration.

Parameters:

config – The Configuration object containing address information.

ControlPlane(const ControlPlane &other)

Copy constructor.

Parameters:

other – Other Control Plane

ControlPlane(ControlPlane &&other) noexcept

Move constructor.

Parameters:

other – Other Control Plane

ControlPlane &operator=(const ControlPlane &other)

Copy assignment operator.

Parameters:

other – Other Control Plane

Returns:

this

ControlPlane &operator=(ControlPlane &&other) noexcept

Move assignment operator.

Parameters:

other – Other Control Plane

Returns:

this

~ControlPlane()

Destroy the ControlPlane object.

absl::string_view getEndpoint() const

ArmoniK control plane endpoint.

Note

Configuration key: `GrpcClient__Endpoint`

Returns:

Endpoint address

absl::string_view getUserCertPemPath() const

Path to the client’s certificate in PEM format.

Note

Configuration key: `GrpcClient__CertPem` (optional)

Returns:

Client certificate’s path

absl::string_view getUserKeyPemPath() const

Path to the client’s key in PEM format (PKCS#1 or PKCS#8)

Note

Configuration key: `GrpcClient__KeyPem` (optional)

Returns:

Client key path

absl::string_view getUserP12Path() const

Path to the client’s PKCS#12 certificate/key.

Note

Configuration key: `GrpcClient__CertP12` (optional)

Returns:

Client P12 path

absl::string_view getCaCertPemPath() const

Path to the server’s CA certificate.

Note

Configuration key: `GrpcClient__CaCert` (optional)

Returns:

CA certificate path

bool isSslValidation() const

Is SSL validation enabled ?

Note

Configuration key: `GrpcClient__AllowUnsafeConnection` (default: false)

Returns:

True if SSL validation is enabled, false otherwise

int getWaitBatchSize() const

Batch size for waiting results.

Note

Configuration key: `GrpcClient__WaitBatchSize` (default: 200)

Returns:

Batch size

int getSubmitBatchSize() const

Batch size for task submission.

Note

Configuration key: `GrpcClient__SubmitBatchSize` (default: 200)

Returns:

Batch size

int getThreadPoolSize() const

Number of threads in the thread pool to upload and download results.

Note

Configuration key: `GrpcClient__ThreadPoolSize` (default: 0)

Note

0 means hardware concurrency

Returns:

Thread pool size

int getOverrideMessageSize() const

Override the message size for result upload and creation.

Note

Configuration key: `GrpcClient__OverrideMessageSize` (default: 0)

Note

When 0, use the message size from the server

Returns:

Message size

Private Functions

const armonik::api::common::options::ControlPlane &get_impl() const
armonik::api::common::options::ControlPlane &set_impl()

Private Members

std::unique_ptr<armonik::api::common::options::ControlPlane> impl
int wait_batch_size_
int submit_batch_size_
int thread_pool_size_
int override_message_size_
struct ConventionPayload

Convention task payload using JSON encoding.

Internal wire format for the convention execution path. Serialized format: {“method”:”<method_name>”,”inputs”:{…},”outputs”:{…}}

Note

This is an internal SDK type. It is not part of the public API and may change or be removed in any future release without notice.

Public Functions

ConventionPayload() = default
std::string Serialize() const

Public Members

std::string method_name
std::map<std::string, std::string> inputs
std::map<std::string, std::string> outputs

Public Static Functions

static ConventionPayload Deserialize(absl::string_view serialized)
class ConventionService : private ArmoniK::Sdk::Worker::ServiceBase

Public Functions

inline virtual std::string call(void*, const std::string &name, const std::map<std::string, std::string> &inputs) override

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

inline virtual void *enter_session(const char *session_id) override

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx) override

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

Private Functions

virtual std::string call(void *session_ctx, const std::string &name, const std::string &input)

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

struct Duration
#include <Duration.h>

Simple duration structure.

Public Members

int64_t seconds = 0

Seconds.

int32_t nanos = 0

Nanoseconds.

class DynamicLib
#include <DynamicLib.h>

Manage external dynamic library.

Public Functions

DynamicLib() noexcept = default

Default constructor.

DynamicLib points to no library

explicit DynamicLib(const char *filename)

Load a library constructor.

Parameters:

filename – path to the library to load

DynamicLib(const DynamicLib&) = delete

Deleted copy constructor.

DynamicLib &operator=(const DynamicLib&) = delete

Deleted copy assignment operator.

inline DynamicLib(DynamicLib &&other) noexcept

Move constructor.

Parameters:

other – Other DynamicLib

inline DynamicLib &operator=(DynamicLib &&other) noexcept

Move assignment operator.

Parameters:

other – Other DyncmicLib

Returns:

this

~DynamicLib()

Destructor.

void unload()

Unload the library.

void *get(const char *symbol_name) const

Retrieve symbol from lib.

Parameters:

symbol_name – Name of the symbol

Returns:

Function pointer for the requested symbol

template<class T>
inline T get(const char *symbol_name) const

Retrieve symbol from lib.

Template Parameters:

T – Function pointer type

Parameters:

symbol_name – Name of the symbol

Returns:

Function pointer for the requested symbol

inline explicit operator bool() const noexcept

Test whether a library is loaded or not.

Returns:

true if a library is loaded

Private Members

void *handle = nullptr

Native handle to the dlopen’ed library.

struct DynamicLibrary
#include <DynamicLibrary.h>

Helper structure holding information to perform dynamic lib loading.

Public Members

std::string library_path
std::string symbol
std::string library_blob_id

Public Static Attributes

static constexpr const char *KeyConventionVersion = "ConventionVersion"
static constexpr const char *KeyLibraryPath = "LibraryPath"
static constexpr const char *KeySymbol = "Symbol"
static constexpr const char *KeyLibraryBlobId = "LibraryBlobId"
static constexpr const char *ConventionVersion = "v1"
class DynamicWorker : public armonik::api::worker::ArmoniKWorker
#include <DynamicWorker.h>

ArmoniK Worker that loads a dynamic library and executes method within it.

Public Functions

explicit DynamicWorker(std::unique_ptr<armonik::api::grpc::v1::agent::Agent::Stub> agent, const ArmoniK::Sdk::Common::Configuration &config, const armonik::api::common::logger::Logger &logger)

Creates a dynamic worker.

Parameters:
  • agent – Stub to communicate with the scheduling agent

  • config – Configuration

armonik::api::worker::ProcessStatus Execute(armonik::api::worker::TaskHandler &taskHandler) override

Executes the task given by the task handler.

Parameters:

taskHandler – Task handler

Returns:

Whether the task executed successfully or not

Private Members

armonik::api::common::logger::LocalLogger logger

Local logger.

ArmoniK::Sdk::DynamicWorker::ApplicationManager manager

Application manager.

class EchoService : private ArmoniK::Sdk::Worker::ServiceBase
#include <EchoService.h>

Example implementation of a ArmoniK::Sdk::Worker::ServiceBase.

Example implementation of a ArmoniK::Sdk::Worker::ServiceBase

Public Functions

inline virtual std::string call(void*, const std::string &name, const std::string &input) override

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

inline virtual void *enter_session(const char *session_id) override

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx) override

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

inline ~EchoService() override
inline EchoService()

Private Functions

virtual std::string call(void *session_ctx, const std::string &name, const std::map<std::string, std::string> &inputs)

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

class ExceptionService : private ArmoniK::Sdk::Worker::ServiceBase
#include <ExceptionService.h>

Example implementation of a ArmoniK::Sdk::Worker::ServiceBase.

Public Functions

inline virtual std::string call(void*, const std::string &name, const std::string &input) override

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

inline virtual void *enter_session(const char *session_id) override

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx) override

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

inline ~ExceptionService() override
inline ExceptionService()

Private Functions

virtual std::string call(void *session_ctx, const std::string &name, const std::map<std::string, std::string> &inputs)

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

class IServiceInvocationHandler

Task result handler interface class.

Public Functions

inline virtual void HandleResponse(const std::string &result_payload, const std::string &taskId, const std::string &result_id)

Callback function called when a task succeeds.

Override this version. The default delegates to the deprecated two-parameter overload for backward compatibility with existing handlers that already override it.

Note

Called concurrently for multiple tasks; implementation must be thread-safe.

Parameters:
  • result_payload – Task result

  • taskId – Task Id

  • result_id – Blob ID of the result in ArmoniK storage; pass to BlobDefinition::FromBlobId to use this result as an input for a subsequent task without re-uploading.

inline virtual void HandleResponse(const std::string &result_payload, const std::string &taskId)

Legacy callback overload — override the three-parameter version instead.

Deprecated:

Override HandleResponse(result_payload, taskId, result_id) instead. This overload exists only for backward compatibility and will be removed in a future release.

virtual void HandleError(const std::exception &e, const std::string &taskId) = 0

Callback function called when a tasks fails.

Note

It can be called for multiple tasks in parallel, so it must be thread-safe

Parameters:
  • e – Risen error

  • taskId – Task Id

struct Properties
#include <Properties.h>

Client properties.

Public Members

Configuration configuration

Configuration.

TaskOptions taskOptions

Default task options.

class SegFaultService : private ArmoniK::Sdk::Worker::ServiceBase
#include <SegFaultService.h>

Example implementation of a ArmoniK::Sdk::Worker::ServiceBase.

Public Functions

inline virtual std::string call(void*, const std::string &name, const std::string &input) override

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

inline virtual void *enter_session(const char *session_id) override

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx) override

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

inline ~SegFaultService() override
inline SegFaultService()

Private Functions

virtual std::string call(void *session_ctx, const std::string &name, const std::map<std::string, std::string> &inputs)

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

class ServiceBase
#include <ServiceBase.h>

Base class to implement a worker in ArmoniK.

Note

This class is useful for use with the ArmoniK.SDK.Worker library which uses the ArmoniK SDK Interface

Subclassed by ArmoniK::Sdk::Worker::Test::AdditionService, ArmoniK::Sdk::Worker::Test::ConventionService, ArmoniK::Sdk::Worker::Test::EchoService, ArmoniK::Sdk::Worker::Test::ExceptionService, ArmoniK::Sdk::Worker::Test::SegFaultService, ArmoniK::Sdk::Worker::Test::SleepService, ArmoniK::Sdk::Worker::Test::StressTest

Public Functions

inline virtual void *enter_session(const char *session_id)

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx)

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

virtual std::string call(void *session_ctx, const std::string &name, const std::map<std::string, std::string> &inputs)

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

virtual std::string call(void *session_ctx, const std::string &name, const std::string &input)

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

virtual ~ServiceBase() = default

Service destructor.

struct ServiceId
#include <ContextIds.h>

Id of a service.

Public Functions

ServiceId() = default

Empty service id.

inline ServiceId(AppId appId, std::string service_namespace, std::string service_name)

Creates a service id.

Note

AppId may not be empty

Note

Service name and namespace can be empty and still be a valid service id (for use in an application with a single service for example)

Parameters:
  • appId – Application id of this service

  • service_namespace – Namespace of the service

  • service_name – Name of the service

inline bool operator==(const ServiceId &other) const

Equality operator.

Parameters:

other – Other ServiceId

Returns:

true if the ServiceIds’ fields are equal

inline bool operator!=(const ServiceId &other) const

Inequality operator.

Parameters:

other – Other ServiceId

Returns:

false if the ServiceIds’ fields are equal

inline bool empty() const

Checks if the ServiceId is empty.

Returns:

True if the application id is empty

inline void clear()

Clears service id.

Public Members

AppId appId

Id of the application of the service.

std::string service_name

Name of the service.

Note

Can be empty

std::string service_namespace

Namsepace of the service.

Note

Can be empty

class ServiceManager
#include <ServiceManager.h>

Manager of service for ArmoniK Worker.

Public Functions

ServiceManager() = default

Empty manager.

ServiceManager(ArmoniKFunctionPointers functionsPointers, ServiceId serviceId)

Manager for the given service.

Parameters:
  • functionsPointers – Dynamic library function pointers

  • serviceId – Service Id

~ServiceManager()
ServiceManager(const ServiceManager&) = delete
ServiceManager &operator=(const ServiceManager&) = delete
inline ServiceManager(ServiceManager &&other) noexcept

Move constructor.

Parameters:

other – Other ServiceManager

inline ServiceManager &operator=(ServiceManager &&other) noexcept

Move assignment operator.

Parameters:

other – Other ServiceManager

Returns:

this

ServiceManager &UseSession(const std::string &sessionId) &

Configure the service to use the given session.

Parameters:

sessionId – Session id

Returns:

the service manager itself If a different session is in use in the service, it will leave the session before entering the new one. If the current session is the same as the requested session, this call does nothing.

armonik::api::worker::ProcessStatus Execute(armonik::api::worker::TaskHandler &taskHandler, const std::string &method_name, const std::string &method_arguments)

Executes a method from the current service, in the current session.

Parameters:
  • taskHandlerArmoniK task handler

  • method_name – Name of the method to call

  • method_arguments – Method’s serialized arguments

Returns:

Task execution status

bool matches(const ServiceId &service_id)

Checks if the current service matches the given service id.

Parameters:

service_id – Service id to check against

Returns:

true if the current service matches the one given

void clear()

Destroys the current service.

Private Members

ServiceId serviceId

Current service id.

std::string current_session

Current session id.

void *service_context = {}

Current service context.

void *session_context = {}

Current session context.

ArmoniKFunctionPointers functionPointers = {}

Library function pointers.

Private Static Functions

static void UploadResult(void *opaque_context, armonik_status_t status, const char *data, size_t data_size)

Callback for the armonik_call.

Parameters:
  • opaque_context – Context

  • statusArmoniK call status

  • data – Output data or error message

  • data_size – Output size

class SessionService
#include <SessionService.h>

Service used for task submission.

Public Functions

explicit SessionService(const ArmoniK::Sdk::Common::Properties &properties, armonik::api::common::logger::Logger &logger, const std::string &session_id = "")

Creates a SessionService from the given Properties.

Parameters:
  • properties – Session properties

  • logger – logger

  • session_id – session id to open, leave blank to open a new session

SessionService(const SessionService&) = delete
SessionService(SessionService &&other) noexcept

Move constructor.

Parameters:

other – Other session service

SessionService &operator=(const SessionService&) = delete
SessionService &operator=(SessionService &&other) noexcept

Move assignment operator.

Parameters:

other – Other session service

Returns:

this

~SessionService()
std::vector<std::string> Submit(const std::vector<Common::TaskPayload> &requests, std::shared_ptr<IServiceInvocationHandler> handler, const ArmoniK::Sdk::Common::TaskOptions &task_options)

Submits the given list of task requests.

Parameters:
  • requests – List of task requests

  • handler – Result handler for this batch of requests

  • task_options – Task options to use for this batch of requests

Returns:

List of task ids

std::vector<std::string> Submit(const std::vector<Common::TaskPayload> &requests, std::shared_ptr<IServiceInvocationHandler> handler)

Submits the given list of task requests using the session’s task options.

Parameters:
  • requests – List of task requests

  • handler – Result handler for this batch of requests

Returns:

List of task ids

std::vector<std::string> Submit(const std::vector<Common::TaskDefinition> &requests, std::shared_ptr<IServiceInvocationHandler> handler, const ArmoniK::Sdk::Common::TaskOptions &task_options)

Submits the given list of task definitions using the session’s task options. Raw input data in each TaskDefinition is uploaded automatically before task submission. Callers do not need to pre-allocate result IDs or upload blobs manually.

Parameters:
  • requests – List of task definitions

  • handler – Result handler for this batch of requests

  • task_options – Task options to use for this batch of requests

Returns:

List of task ids

std::vector<std::string> Submit(const std::vector<Common::TaskDefinition> &requests, std::shared_ptr<IServiceInvocationHandler> handler)

Submits the given list of task definitions using the session’s task options. Raw input data in each TaskDefinition is uploaded automatically before task submission. Callers do not need to pre-allocate result IDs or upload blobs manually.

Parameters:
  • requests – List of task definitions

  • handler – Result handler for this batch of requests

Returns:

List of task ids

void UploadLibrary(const std::string &library_path, Common::DynamicLibrary &lib)

Uploads a shared library (.so) to ArmoniK blob storage and stores the resulting blob ID in lib. After this call, lib is ready to be passed to TaskOptions::SetDynamicLibrary().

The blob is automatically added as a data dependency for each task submitted with that DynamicLibrary, so the worker can download and dlopen the library at runtime without requiring the file to exist on the worker’s local filesystem.

Parameters:
  • library_path – Filesystem path to the .so file to upload

  • lib – DynamicLibrary whose library_blob_id field will be set to the uploaded blob ID

void WaitResults(std::set<std::string> task_ids = {}, WaitBehavior waitBehavior = All, const WaitOptions &options = WaitOptions())

Waits for the completion of the given tasks.

Note

When waiting for all tasks to finish, if tasks are being submitted concurrently with the wait, this function may return before the concurrent tasks submission is complete

Parameters:
  • task_ids – Task ids to wait on. If left empty, will wait for submitted tasks in

  • waitBehavior – Wait for all tasks completion, any task completion and/or stop waiting if a result is aborted

  • options – Wait options

const std::string &getSession() const

Get the session Id associated with this service.

Returns:

Session Id

void DropSession()

Discards all results, cancels the tasks and cancels the session. No handler will be called.

Warning

The session and its data will not be recoverable.

Warning

Using this on a session with running or pending tasks will result in undefined behavior

void CloseSession()

Closes the session for the current service

void CancelSession()

Closes the session for the current service

void PurgeSession()

Purges the session for the current service

void CleanupTasks(std::vector<std::string> task_ids)

Discards the results data of the given tasks. The associated results must be completed or aborted.

Warning

The data of these results will not be recoverable. Tasks which depend on these data will fail.

Warning

The tasks will not be processed by the client.

Parameters:

task_ids – Task ids

Private Functions

void ensure_valid() const

Private Members

std::unique_ptr<ArmoniK::Sdk::Client::Internal::SessionServiceImpl> impl
armonik::api::common::logger::LocalLogger logger_
class SleepService : private ArmoniK::Sdk::Worker::ServiceBase
#include <SleepService.h>

Example implementation of a ArmoniK::Sdk::Worker::ServiceBase.

Public Functions

inline virtual std::string call(void*, const std::string &name, const std::string &input) override

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

inline virtual void *enter_session(const char *session_id) override

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx) override

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

inline ~SleepService() override
inline SleepService()

Private Functions

virtual std::string call(void *session_ctx, const std::string &name, const std::map<std::string, std::string> &inputs)

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

class StressTest : public ArmoniK::Sdk::Worker::ServiceBase

Public Functions

inline virtual void *enter_session(const char *session_id) final

Method called when entering a session.

Parameters:

session_id – Null terminated id of the session

Returns:

A user defined session context. May return null.

inline virtual void leave_session(void *session_ctx) final

Method called when leaving a session.

Warning

This function should free all resources contained in the session context

Parameters:

session_ctx – User provided session context

inline virtual std::string call(void*, const std::string &name, const std::string &input) final

Legacy entry point: called with the raw serialized payload. Override this when using the legacy execution path (application_name / application_version). The default implementation parses the payload as convention JSON and delegates to the map overload.

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • input – Raw payload — JSON for convention tasks, binary for legacy tasks

Returns:

Result string stored as a blob

~StressTest() final = default
inline std::vector<double> compute_workload(const std::vector<double> &input, const std::size_t nbOutputBytes, const std::uint32_t workLoadTimeInMs) noexcept
virtual std::string call(void *session_ctx, const std::string &name, const std::map<std::string, std::string> &inputs)

Convention-path entry point: called with named, already-resolved inputs. Override this when using the convention execution path (TaskDefinition / SetDynamicLibrary).

Parameters:
  • session_ctx – User provided session context

  • name – Name of the called method

  • inputs – Named inputs map (key → resolved string value)

Returns:

Result string stored as a blob

struct TaskDefinition
#include <TaskDefinition.h>

User-facing task descriptor for the convention execution path.

Unlike TaskPayload (which requires callers to pre-allocate result IDs for every input), TaskDefinition accepts raw data directly. The SDK uploads all raw inputs on the caller’s behalf during Submit(), so callers only need to provide the data they want to send.

Inputs that were already uploaded (e.g. a shared large dataset) can be referenced by blob ID via BlobDefinition::FromBlobId() to avoid re-uploading.

Example:

service.Submit({
  TaskDefinition{"my_method", {
    {"param_a", BlobDefinition::FromData(raw_bytes_a)},
    {"param_b", BlobDefinition::FromBlobId(existing_blob_id)},
  }}
}, handler);

Public Functions

TaskDefinition() = default
inline TaskDefinition(std::string method_name_, std::map<std::string, BlobDefinition> inputs_)
inline TaskDefinition &WithInput(std::string name, BlobDefinition blob)

Adds a named input to this task definition.

Parameters:
  • name – Input name

  • blob – Blob definition (raw data or existing blob ID)

Returns:

*this for chaining

Public Members

std::string method_name

Method name to dispatch to on the worker.

std::map<std::string, BlobDefinition> inputs

Named inputs: maps a user-defined name to a BlobDefinition (raw data or blob ref)

struct TaskOptions
#include <TaskOptions.h>

Simplified TaskOptions.

Public Functions

TaskOptions(std::string applicationName, std::string applicationVersion, std::string applicationNamespace, std::string applicationService, std::string partitionId = "", std::string engineType = "", int priority = 2, int maxRetries = 3, const Duration &maxDuration = {300, 0}, const std::map<std::string, std::string> &options = std::map<std::string, std::string>())

Creates a task option.

Parameters:
  • applicationName – Application name, used when loading the worker library

  • applicationVersion – Application version, used when loading the worker library

  • applicationNamespace – Application namespace, used when creating the service of the worker library

  • applicationService – Application service, used when creating the service of the worker library

  • partitionId – Infrastructure partition to send the task to, defaults to “”

  • engineType – SDK engine type (unused in the C++ SDK), defaults to “”

  • priority – Task priority, defaults to 2

  • maxRetries – Max number of retries for the task, defaults to 3

  • maxDuration – Max task duration, defaults to 5 minutes

  • options – User defined options map, defaults to an empty map

explicit TaskOptions(const armonik::api::grpc::v1::TaskOptions &raw)

Converts an ArmoniK compatible TaskOptions object to this TaskOptions object.

Parameters:

rawArmoniK compatible task options

explicit operator armonik::api::grpc::v1::TaskOptions() const

Converts this TaskOptions object to an ArmoniK compatible object.

Returns:

ArmoniK compatible TaskOptions object

void SetDynamicLibrary(const DynamicLibrary &lib)

Encodes a DynamicLibrary into this->options using the convention keys. Also sets the ConventionVersion key.

Parameters:

libDynamicLibrary to encode

DynamicLibrary GetDynamicLibrary() const

Decodes a DynamicLibrary from this->options.

Throws:

ArmoniKSdkException – if the LibraryPath key is missing

Returns:

Decoded DynamicLibrary

std::string GetConventionVersion() const

Returns the ConventionVersion value from this->options.

Throws:

ArmoniKSdkException – if the ConventionVersion key is absent

Returns:

Convention version string

Public Members

std::string application_name

Application name, used when loading the worker library.

std::string application_version

Application version, used when loading the worker library.

std::string application_namespace

Application namespace, used when creating the service of the worker library.

std::string application_service

Application service, used when creating the service of the worker library.

std::string partition_id

Infrastructure partition to send the task to.

std::string engine_type

SDK engine type (unused in the C++ SDK)

int priority

Task priority.

int max_retries

Max number of retries for the task.

Duration max_duration

Max task duration.

std::map<std::string, std::string> options

User defined options map.

struct TaskPayload
#include <TaskPayload.h>

Task payload using custom binary encoding. Used on the legacy execution path (application_name / application_version based loading).

Deprecated:

Use TaskDefinition with Submit(std::vector<TaskDefinition>) instead.

Public Functions

TaskPayload() = default
inline TaskPayload(std::string method_name_, std::string arguments_, std::vector<std::string> data_dependencies_ = std::vector<std::string>())

Constructs a task payload.

Parameters:
  • method_name_ – Method name

  • arguments_ – Serialized arguments for the method

  • data_dependencies_ – Data dependencies for the task. Empty by default

std::string Serialize() const

Serializes the payload into the legacy binary format.

Returns:

Serialized payload

Public Members

std::string method_name

Task’s method name.

std::string arguments

Method’s serialized arguments.

std::vector<std::string> data_dependencies

Task’s data dependencies.

Public Static Functions

static TaskPayload Deserialize(absl::string_view serialized)

Deserializes a payload from the legacy binary format.

Parameters:

serialized – Serialized payload

Returns:

Deserialized payload

struct WaitOptions
#include <WaitBehavior.h>

Options for result waiting.

Public Members

unsigned int polling_ms = 500

Time in milliseconds for result status polling.

unsigned int timeout = UINT_MAX

Timeout before returning in milliseconds.

namespace ArmoniK

Proxy function definitions.

namespace armonik

This file declares proxy objects for the Configuration objects.

namespace api
namespace common
namespace options
namespace utils
namespace grpc
namespace v1
namespace worker
namespace Sdk
namespace Client

Enums

enum WaitBehavior

Values:

enumerator All

Wait on all tasks completion

enumerator Any

Wait on any task completion

enumerator BreakOnError

Stop waiting for all tasks if any one of them has an error

Functions

inline enum WaitBehavior operator|(WaitBehavior a, WaitBehavior b)
namespace Internal
namespace Common

Typedefs

typedef uint32_t field_size_t

Functions

inline std::string to_lower(std::string str)
inline std::string to_capitalized(std::string str)
namespace Common
namespace Common
namespace DynamicWorker
namespace DynamicWorker
namespace Worker
namespace Test
namespace std
file IServiceInvocationHandler.h
#include <stdexcept>
#include <string>
file SessionService.h
#include “WaitBehavior.h
#include <armonik/common/logger/formatter.h>
#include <armonik/common/logger/logger.h>
#include <armonik/common/logger/writer.h>
#include <memory>
#include <set>
#include <string>
#include <vector>
file WaitBehavior.h
#include <climits>
file Batcher.h
file ChannelPool.h
#include <armonik/common/logger/formatter.h>
#include <armonik/common/logger/logger.h>
#include <armonik/common/logger/writer.h>
#include <grpcpp/channel.h>
#include <mutex>
#include <queue>
file Function.h
#include <armonik/common/logger/formatter.h>
#include <armonik/common/logger/logger.h>
#include <armonik/common/logger/writer.h>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <thread>
#include <vector>
file SessionServiceImpl.h
#include “ChannelPool.h
#include “ThreadPool.h
#include <armonik/client/results/ResultsClient.h>
#include <mutex>
#include <results_service.grpc.pb.h>
file ThreadPool.h
#include “Function.h
#include <armonik/common/logger/formatter.h>
#include <armonik/common/logger/logger.h>
#include <armonik/common/logger/writer.h>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <queue>
#include <thread>
#include <vector>
file ChannelPool.cpp
#include “ChannelPool.h
#include <armonik/client/channel/ChannelFactory.h>
#include <armonik/common/options/ControlPlane.h>
#include <armonik/common/utils/ChannelArguments.h>
#include <armonik/sdk/common/Version.h>
#include <grpcpp/create_channel.h>
#include <utility>
file SessionService.cpp
#include “SessionServiceImpl.h
#include <armonik/sdk/common/Version.h>
#include <fstream>
#include <sstream>
#include <string>
#include <utility>
file SessionServiceImpl.cpp
#include “SessionServiceImpl.h
#include “Batcher.h
#include <armonik/client/results/ResultsClient.h>
#include <armonik/client/results_common.pb.h>
#include <armonik/client/results_service.grpc.pb.h>
#include <armonik/client/sessions/SessionsClient.h>
#include <armonik/client/sessions_service.grpc.pb.h>
#include <armonik/client/tasks/TasksClient.h>
#include <armonik/client/tasks_service.grpc.pb.h>
#include <armonik/common/exceptions/ArmoniKApiException.h>
#include <armonik/common/exceptions/ArmoniKTaskError.h>
#include <armonik/common/objects.pb.h>
#include <armonik/common/utils/GuuId.h>
#include <armonik/sdk/common/Version.h>
#include <chrono>
#include <thread>
#include <utility>
#include <vector>
file ThreadPool.cpp
#include “ThreadPool.h
#include <sstream>
#include <string>
file ArmoniKSdkException.h
#include <stdexcept>
file BlobDefinition.h
#include <string>
file Configuration.h
#include <absl/strings/string_view.h>
#include <armonik/common/logger/fwd.h>
#include <map>
#include <memory>
#include <string>
file Duration.h
#include <cstdint>
file DynamicLibrary.h
#include <string>
file ConventionPayload.h
#include <absl/strings/string_view.h>
#include <map>
#include <string>
file Properties.h
#include “Configuration.h
#include “TaskOptions.h
file TaskDefinition.h
#include “BlobDefinition.h
#include <map>
#include <string>
file TaskOptions.h
#include “Duration.h
#include “DynamicLibrary.h
#include <map>
#include <memory>
#include <string>
file TaskPayload.h
#include <absl/strings/string_view.h>
#include <map>
#include <sstream>
#include <vector>
file Utils.h
#include <algorithm>
#include <cctype>
#include <string>
file Configuration.cpp
#include <armonik/common/logger/level.h>
#include <armonik/common/options/ComputePlane.h>
#include <armonik/common/options/ControlPlane.h>
#include <armonik/common/utils/Configuration.h>
#include <utility>
file DynamicLibrary.cpp
file TaskOptions.cpp
#include <armonik/common/objects.pb.h>
file TaskPayload.cpp
#include <cstdint>
#include <iomanip>
#include <nlohmann/json.hpp>
#include <string>

Defines

REGISTER_PARSE_TYPE(X)

Variables

static const char *name
file ApplicationManager.h
#include “ContextIds.h
#include “DynamicLib.h
#include “ServiceManager.h
#include <Worker/ProcessStatus.h>
#include <armonik/common/logger/logger.h>
#include <armonik/worker/Worker/TaskHandler.h>
#include <map>
#include <string>
file ContextIds.h
#include <functional>
#include <string>
#include <utility>
file DynamicLib.h
#include <utility>
file DynamicWorker.h
#include “ApplicationManager.h
#include <armonik/common/logger/local_logger.h>
#include <armonik/worker/Worker/ArmoniKWorker.h>
file ServiceManager.h
#include “ContextIds.h
#include <armonik/worker/Worker/ProcessStatus.h>
#include <armonik/worker/Worker/TaskHandler.h>
file ApplicationManager.cpp
#include “ApplicationManager.h
#include <sstream>
file DynamicLib.cpp
#include “DynamicLib.h
#include <dlfcn.h>
#include <stdexcept>
file DynamicWorker.cpp
#include “DynamicWorker.h
#include “ApplicationManager.h
#include <exception>
#include <fstream>
file main.cpp
#include “DynamicWorker.h
#include <armonik/sdk/common/Version.h>
#include <armonik/worker/utils/WorkerServer.h>

Functions

int main()
file ServiceManager.cpp
#include “ServiceManager.h
#include “ContextIds.h
#include <armonik/worker/Worker/ProcessStatus.h>
#include <stdexcept>
#include <utility>

Variables

armonik::api::worker::TaskHandler &taskHandler
armonik::api::worker::ProcessStatus output
bool retry_requested = false
std::string retry_message
file AdditionService.h
#include <cstdint>
#include <iostream>
#include <stdexcept>
file ConventionService.h
#include <map>
#include <stdexcept>
#include <string>
file EchoService.h
#include <iostream>
file ExceptionService.h
#include <iostream>
file SegFaultService.h
#include <iostream>
file SleepService.h
#include <chrono>
#include <iostream>
#include <thread>
file StressTest.h
#include <algorithm>
#include <chrono>
#include <cstring>
#include <iostream>
#include <numeric>
#include <vector>
file ServiceDispatch.cpp
#include <cstring>
#include <iostream>
#include “AdditionService.h
#include “ConventionService.h
#include “EchoService.h
#include “ExceptionService.h
#include “SegFaultService.h
#include “SleepService.h
#include “StressTest.h

Functions

void *armonik_create_service(const char *service_namespace, const char *service_name)

Function called when requesting a service creation.

Warning

When using the ArmoniK.SDK.Worker library, this function is the only mandatory one to be implemented and MUST return a pointer to a subclass of ArmoniK::Sdk::Worker::ServiceBase

Parameters:
  • service_namespace – Namespace of the requested service, may be empty

  • service_name – Name of the requested service

Returns:

A user defined service context

file ArmoniKSDKInterface.h
#include <stddef.h>

Low level interface to communicate between the DynamicWorker and the loaded library.

This file can be used as-is to implement a DynamicWorker-compatible library. You may also use the ArmoniK.SDK.Worker library to have a simple wrapper.

Typedefs

typedef enum armonik_status_t armonik_status_t

ArmoniK call status .

typedef void *(*armonik_create_service_t)(const char *service_namespace, const char *service_name)

armonik_create_service function typedef

typedef void (*armonik_destroy_service_t)(void *service_context)

armonik_destroy_service function typedef

typedef void *(*armonik_enter_session_t)(void *service_context, const char *session_id)

armonik_enter_session function typedef

typedef void (*armonik_leave_session_t)(void *service_context, void *session_context)

armonik_leave_session function typedef

typedef void (*armonik_callback_t)(void *armonik_context, armonik_status_t status, const char *output_or_error, size_t output_size)

armonik_callback function typedef

typedef armonik_status_t (*armonik_call_t)(void *armonik_context, void *service_context, void *session_context, const char *function_name, const char *input, size_t input_size, armonik_callback_t callback)

armonik_call function typedef

Enums

enum armonik_status_t

ArmoniK call status .

Values:

enumerator ARMONIK_STATUS_OK

Successful call.

enumerator ARMONIK_STATUS_ERROR

Failed call, not retryable.

Note

Use this status for permanent failures. The task will be marked as Error and will not be retried.

Note

When using the ArmoniK.SDK.Worker library, throwing an ArmoniK::Sdk::Common::ArmoniKSdkException from ServiceBase::call() will automatically produce this status.

enumerator ARMONIK_STATUS_RETRY

Failed call, retryable.

Note

Use this status for transient failures. ArmoniK will retry the task according to the task’s retry policy (TaskOptions::max_retries).

Note

When using the ArmoniK.SDK.Worker library, any exception other than ArmoniK::Sdk::Common::ArmoniKSdkException thrown from ServiceBase::call() will automatically produce this status.

Functions

void *armonik_create_service(const char *service_namespace, const char *service_name)

Function called when requesting a service creation.

Warning

When using the ArmoniK.SDK.Worker library, this function is the only mandatory one to be implemented and MUST return a pointer to a subclass of ArmoniK::Sdk::Worker::ServiceBase

Parameters:
  • service_namespace – Namespace of the requested service, may be empty

  • service_name – Name of the requested service

Returns:

A user defined service context

void armonik_destroy_service(void *service_context)

Function called when requesting the destruction of a service.

Note

When using the ArmoniK.SDK.Worker library, this function is already implemented and the service_context is a ServiceBase. You can override this method to add functionality but you should also call armonik_destroy_service_default to destroy the service_context.

Parameters:

service_context – User defined service context

void *armonik_enter_session(void *service_context, const char *session_id)

Function called when entering a session.

Note

When using the ArmoniK.SDK.Worker library, this function is already implemented and calls the enter_session method of the service.

Parameters:
  • service_context – User defined service context

  • session_id – session id

Returns:

User defined session context

void armonik_leave_session(void *service_context, void *session_context)

Function called when leaving a session.

Note

When using the ArmoniK.SDK.Worker library, this function is already implemented and calls the leave_session method of the service.

Parameters:
  • service_context – User defined service context

  • session_context – User defined session context

armonik_status_t armonik_call(void *armonik_context, void *service_context, void *session_context, const char *function_name, const char *input, size_t input_size, armonik_callback_t callback)

Function called when requesting the execution of a method.

Parameters:
  • armonik_context – Opaque ArmoniK context, should be passed to the callback as-is without modification

  • service_context – User defined service context

  • session_context – User defined session context

  • function_name – Name of the function to call

  • input – Serialized arguments for the function

  • input_size – size of the serialized arguments

  • callback – Callback provided by ArmoniK to send the result of the execution or details on a failure

Returns:

Status of the call. See /ref armonik_status_t for more details

file ServiceBase.h
#include <map>
#include <string>
file ArmoniKSDKInterface.cpp
#include <cstring>

Functions

void armonik_destroy_service_default(void *p)
void armonik_destroy_service(void *p)
void *armonik_enter_session_default(void *service_context, const char *session_id)
void *armonik_enter_session(void *service_context, const char *session_id)
void armonik_leave_session_default(void *service_context, void *session_context)
void armonik_leave_session(void *service_context, void *session_context)
armonik_status_t armonik_call_default(void *armonik_context, void *service_context, void *session_context, const char *function_name, const char *input, size_t input_size, armonik_callback_t callback)
armonik_status_t armonik_call(void *armonik_context, void *service_context, void *session_context, const char *function_name, const char *input, size_t input_size, armonik_callback_t callback)
file ServiceBase.cpp
#include <nlohmann/json.hpp>
file README.md
page ArmoniK.Extensions.Cpp

This project is part of the ArmoniK project. The ArmoniK C++ SDK is used by developers to create ArmoniK applications. This SDK contains a high-level API, programs, and tools, including code samples, libraries, documentation, and docker images to ease the compile and build process of client and worker binaries on multiple target platforms such as Ubuntu, and Redhat. It also provides guides that help developers to create a software application for use on ArmoniK. ArmoniK C++ SDK provides everything developers need to get their applications ready for production quickly and efficiently.

Documentation

Please, read the documentation for more information about ArmoniK.Extensions.Cpp.

The code documentation generated by doxygen can be found here

Installation

To install ArmoniK SDK on your system, please follows these steps.

Setup project

To setup your own client and / or worker, please follows these steps.

Tests

To deploy and test ArmoniK C++ SDK, please follows these steps.

page Deprecated List

Member ArmoniK::Sdk::Client::IServiceInvocationHandler::HandleResponse  (const std::string &result_payload, const std::string &taskId)

Override HandleResponse(result_payload, taskId, result_id) instead. This overload exists only for backward compatibility and will be removed in a future release.

Struct ArmoniK::Sdk::Common::TaskPayload

Use TaskDefinition with Submit(std::vector<TaskDefinition>) instead.

dir ArmoniK.SDK.Client/include/armonik
dir ArmoniK.SDK.Common/include/armonik
dir ArmoniK.SDK.Worker/include/armonik
dir ArmoniK.SDK.Client
dir ArmoniK.SDK.Common
dir ArmoniK.SDK.DynamicWorker
dir ArmoniK.SDK.Worker
dir ArmoniK.SDK.Worker.Test
dir ArmoniK.SDK.Client/include/armonik/sdk/client
dir ArmoniK.SDK.Common/include/armonik/sdk/common
dir ArmoniK.SDK.Client/include
dir ArmoniK.SDK.Common/include
dir ArmoniK.SDK.DynamicWorker/include
dir ArmoniK.SDK.Worker.Test/include
dir ArmoniK.SDK.Worker/include
dir ArmoniK.SDK.Common/include/armonik/sdk/common/internal
dir ArmoniK.SDK.Client/private
dir ArmoniK.SDK.Client/include/armonik/sdk
dir ArmoniK.SDK.Common/include/armonik/sdk
dir ArmoniK.SDK.Worker/include/armonik/sdk
dir ArmoniK.SDK.Client/src
dir ArmoniK.SDK.Common/src
dir ArmoniK.SDK.DynamicWorker/src
dir ArmoniK.SDK.Worker.Test/src
dir ArmoniK.SDK.Worker/src
dir ArmoniK.SDK.Worker/include/armonik/sdk/worker
example AdditionService.h

Example implementation of a ArmoniK::Sdk::Worker::ServiceBase

#pragma once

#include <armonik/sdk/worker/ServiceBase.h>
#include <cstdint>
#include <iostream>
#include <stdexcept>
namespace ArmoniK {
namespace Sdk {
namespace Worker {
namespace Test {

/**
 * \example AdditionService.h
 * Example implementation of a ArmoniK::Sdk::Worker::ServiceBase
 */

/**
 * @brief Example implementation of a ArmoniK::Sdk::Worker::ServiceBase
 */
class AdditionService : ServiceBase {
public:
  void *enter_session(const char *session_id) override {
    std::cout << "AdditionService enter session: " << session_id << std::endl;
    return new std::string(session_id);
  }
  void leave_session(void *session_ctx) override {
    auto sessionId = static_cast<std::string *>(session_ctx);
    std::cout << "AdditionService leave session: " << *sessionId << std::endl;
    delete sessionId;
  }
  std::string call(void *, const std::string &name, const std::string &input) override {
    if (name == "add_ints") {
      char output[sizeof(int32_t)];
      int32_t a, b, c;
      std::memcpy(&a, input.data(), sizeof(int32_t));
      std::memcpy(&b, input.data() + sizeof(int32_t), sizeof(int32_t));
      c = add_ints(a, b);
      std::memcpy(output, &c, sizeof(int32_t));
      return {output, sizeof(int32_t)};
    } else if (name == "add_floats") {
      char output[sizeof(float)];
      float a, b, c;
      std::memcpy(&a, input.data(), sizeof(float));
      std::memcpy(&b, input.data() + sizeof(float), sizeof(float));
      c = add_floats(a, b);
      std::memcpy(output, &c, sizeof(float));
      return {output, sizeof(float)};
    }
    throw std::runtime_error("Unknown method name " + name);
  }

  /**
   * @brief Adds 2 ints
   * @param a A
   * @param b B
   * @return A+B
   */
  int32_t add_ints(int32_t a, int32_t b) {
    (void)this;
    return a + b;
  }

  /**
   * @brief Add 2 floats
   * @param a A
   * @param b B
   * @return A+B
   */
  float add_floats(float a, float b) {
    (void)this;
    return a + b;
  }
};

} // namespace Test
} // namespace Worker
} // namespace Sdk
} // namespace ArmoniK

example ServiceDispatch.cpp

This is an example on how to use the ArmoniK::Sdk::Worker::ServiceBase approach for the ArmoniK Worker See ArmoniK::Sdk::Worker::Test::AdditionService and ArmoniK::Sdk::Worker::Test::EchoService for example implementations

#include <armonik/sdk/worker/ArmoniKSDKInterface.h>
#include <cstring>
#include <iostream>

#include "AdditionService.h"
#include "ConventionService.h"
#include "EchoService.h"
#include "ExceptionService.h"
#include "SegFaultService.h"
#include "SleepService.h"
#include "StressTest.h"

extern "C" void *armonik_create_service(const char *service_namespace, const char *service_name) {
  std::cout << "Creating service < " << service_namespace << "::" << service_name << " >" << std::endl;
  if (std::strcmp(service_name, "AdditionService") == 0) {
    return new ArmoniK::Sdk::Worker::Test::AdditionService();
  } else if (std::strcmp(service_name, "EchoService") == 0) {
    return new ArmoniK::Sdk::Worker::Test::EchoService();
  } else if (std::strcmp(service_name, "StressTest") == 0) {
    return new ArmoniK::Sdk::Worker::Test::StressTest();
  } else if (std::strcmp(service_name, "SegFaultService") == 0) {
    return new ArmoniK::Sdk::Worker::Test::SegFaultService();
  } else if (std::strcmp(service_name, "SleepService") == 0) {
    return new ArmoniK::Sdk::Worker::Test::SleepService();
  } else if (std::strcmp(service_name, "ConventionArithmetic") == 0) {
    return new ArmoniK::Sdk::Worker::Test::ConventionService();
  } else if (std::strcmp(service_name, "ExceptionService") == 0) {
    return new ArmoniK::Sdk::Worker::Test::ExceptionService();
  }
  std::cout << "Unknown service < " << service_namespace << "::" << service_name << " >" << std::endl;
  throw std::runtime_error(std::string("Unknown service <") + service_namespace + "::" + service_name + ">");
}

/** \example ServiceDispatch.cpp
 * This is an example on how to use the ArmoniK::Sdk::Worker::ServiceBase approach for the ArmoniK Worker
 * See ArmoniK::Sdk::Worker::Test::AdditionService and ArmoniK::Sdk::Worker::Test::EchoService for example
 * implementations
 */