radiaction v1.0.0-experimental.3
WARNING! This is an experimental project. It's use is not yet recommended for production. Please, consider helping us on the path to stability by contributing to this project 🍻💪
Agnosticism: With Radiaction, developers don't need to know how/where/when their distributed functions will be running.
Modularity: Encapsulated modules containing actions and reactions next to each other allow developers to keep coding with the mindset of a non distributed application.
Separation of concerns: DevOps don't need to interfere on how developers are writting their functions. Scaling and even changing the infrasctructure can be done independently by DevOps with no change in the application code.
API
Application side
Higher-order functions
emitter
import { emitter } from '@quadric/radiaction'
emitter(actionsMap: Object): Object
For each action, wraps it with a function that:
- when called, dispatches a message to the broker, ultimately triggering the subscribed reaction.
- returns the location of the dispatched message in the broker (async/promise).
topicfy
import { topicfy } from '@quadric/radiaction'
topicfy(moduleName: String)(actionsMap: Object): Object
Sanitizes the functions names while combining them with the provided key (moduleName
). The resulting function names can be used as topic names.
waiter
import { waiter } from '@quadric/radiaction'
waiter(actionsMap: Object): Object
For each action, wraps it with a function that:
- when called, notifies the broker that the given action is waiting for the output of its respective reaction.
- returns the output of its respective reaction once its available (async/promise).
Utilities
compose
import { compose } from '@quadric/radiaction'
compose(...functions: Array<Function>)
Composes functions from right to left. You might want to use it to compose multiple higher-order functions into a single higher-order function.
This is a functional programming utility, and is included here as a convenience. It works exactly like the function of the same name in Recompose and Redux, or lodash's flowRight()
.
Distributed side
createTopics
import { createTopics } from '@quadric/radiaction'
createTopics(actionsMap: Object): Promise
Initializes the topics for every action. It only needs to be executed once.
runner
import { runner } from '@quadric/radiaction'
runner(reactionsMap: Object): Promise
Start runners that will subscribe to the topics associated with each action. It will:
- execute the associated reaction
- notify the broker that the output of the reaction is available.
Examples
Take a look at the examples folder in order to see our available demos.