knix-microfunctions / knix

Serverless computing platform with process-based lightweight function execution and container-based application isolation. Works in Knative and bare metal/VM environments.
https://knix.io
Apache License 2.0
201 stars 26 forks source link

Simplify and unify function worker object creation #115

Closed iakkus closed 3 years ago

iakkus commented 3 years ago

This PR simplifies the object creation by passing the worker parameters, such that the object attributes can be created using a single dictionary. Previously, there were many parameters being passed to each object, such that maintainability and readibility were decreased.

Furthermore, this PR makes simple refactoring changes to the way api objects are created after the fork in FunctionWorker and unifies the way they are created. Previously, state_utils was created in the parent function worker whereas publication_utils, session_utils and sapi were created after the fork. With this PR, they are all created in the parent FunctionWorker; however, they are updated as necessary after the fork (e.g., setting the corresponding key or session_id).

There are also minor tweaks to some tests.

iakkus commented 3 years ago

Another purpose of this PR is to also prepare the codebase for the future modularization of the objects, such that user code can instantiate (e.g., using a library) desired objects for accessing the datalayer, manipulating dynamic workflows or session utils.

iakkus commented 3 years ago

Afaics no functional change here except maybe the removal of publishing to the recovery manager.

Yes, no functional change. Publishing to the recovery manager was actually a no-op (i.e., the responsible function was returning immediately).

A WorkerParams class might be useful, but I don't see, as of right now, much of a difference from the generic dict object, which also works as a map. If in the future there are other capabilities this separate class would give us, we can add it.