wrench::FunctionManager

class FunctionManager : public wrench::Service

A manager for interacting with a serverless compute service.

Public Functions

~FunctionManager() override

Destructor.

std::shared_ptr<Invocation> invokeFunction(const std::shared_ptr<RegisteredFunction> &registered_function, const std::shared_ptr<ServerlessComputeService> &sl_compute_service, const std::shared_ptr<FunctionInput> &function_input)

Invokes a function on a ServerlessComputeService.

Parameters:
  • registered_function – the (registered) function to invoke

  • sl_compute_service – the ServerlessComputeService to invoke the function on

  • function_input – the input (object) to the function

Returns:

std::shared_ptr<Invocation> an Invocation object created by the ServerlessComputeService

bool isDone(const std::shared_ptr<Invocation> &invocation)

State finding method to check if an invocation is done.

Parameters:

invocation – the invocation to check

Returns:

true if the invocation is done

Returns:

false if the invocation is not done

void kill()

Kill the function manager.

std::shared_ptr<RegisteredFunction> registerFunction(const std::shared_ptr<Function> &function, const std::shared_ptr<ServerlessComputeService> &compute_service, double time_limit_in_seconds, sg_size_t disk_space_limit_in_bytes, sg_size_t RAM_limit_in_bytes, sg_size_t ingress_in_bytes, sg_size_t egress_in_bytes)

Registers a function with the ServerlessComputeService.

Parameters:
  • function – the function to register

  • sl_compute_service – the ServerlessComputeService to register the function on

  • time_limit_in_seconds – the time limit for the function execution

  • disk_space_limit_in_bytes – the disk space limit for the function

  • RAM_limit_in_bytes – the RAM limit for the function

  • ingress_in_bytes – the ingress data limit (this is currently completely IGNORED)

  • egress_in_bytes – the egress data limit (this is currently completely IGNORED)

Throws:

ExecutionException – if the function registration fails

Returns:

true if the function was registered successfully

virtual void stop() override

Stop the function manager.

void wait_all(const std::vector<std::shared_ptr<Invocation>> &invocations)

Waits for a list of invocations to finish.

void wait_one(const std::shared_ptr<Invocation> &invocation)

Waits for a single invocation to finish.

Parameters:

invocation – the invocation to wait for

Public Static Functions

static std::shared_ptr<Function> createFunction(const std::string &name, const std::function<std::shared_ptr<FunctionOutput>(const std::shared_ptr<FunctionInput>&, const std::shared_ptr<StorageService>&)> &lambda, const std::shared_ptr<FileLocation> &image)

Creates a shared pointer to a Function object and returns it.

Parameters:
  • name – the name of the function

  • lambda – the code of the function

  • image – the location of image to execute the function on

Returns:

std::shared_ptr<Function> a shared pointer to the Function object created