social-native / kafka-sagas Goto Github PK
View Code? Open in Web Editor NEWUse redux-sagas semantics on top of Kafka.
License: Apache License 2.0
Use redux-sagas semantics on top of Kafka.
License: Apache License 2.0
I would like to propose some additional syntax to control the behavior of an action channel. Initially, I would like to support two new options: transactionVisibility
and deserializer
.
transactionVisibility
can be one of three kinds:
{kind: 'local_transactions'}
(default)
{kind: 'transaction_id', transaction_id: string}
{kind: 'global'}
deserializer
is an option that can replace the default message deserializer, which expects a JSON of shape { transaction_id, headers, payload }
. This deseralizer would still be required to have an output interface of IAction
.The syntax extension I am proposing is as follows:
class AvroDeserializer extends ActionChannelDeserializer {
}
const deserializer = new AvroDeserializer();
function* saga(action, context) {
const channel = context.effects.actionChannel('my_topic', predicateFunction, {
transactionVisibility: {kind: 'global'},
deserializer
});
}
We outlined the following uses for this package:
Worker pod's execution flow
Receive a job from kafka per-job topic
{ job_id: asdf1234 }
Jobs table for just ids
Per-job request table for work to be done { job_id }
Per-job response table for work completed { job_id }
Query mysql for per-job metadata
Call action function in src/background_workers/*
Notify per-job table work was done
In the Saga pattern, compensation is a key aspect of the workflow. This RFC proposes a new effect for us to register compensation to be handled when a saga throws, which will not be subject to the overall timeout of the saga unless otherwise specified.
/** Eagerly send work to some other saga for compensation to be handled. */
type DistributedCompensator<Payload extends DefaultPayload> = {
topic: string;
payload: Payload;
}
/** Compensate with your own function, async function, or workflow (i.e. callable saga). */
type LocalCompensator<Payload extends DefaultPayload> = {
handler: (payload: Payload) => void | Promise<void> | Generator<IEffectDescription, void, any>;
payload: Payload;
}
type CompensationPlan<Payload> = DistributedCompensator<Payload> | LocalCompensator<Payload>;
type DeleteCampaignPayload = {campaign_id: string | number};
function* saga ({payload}, {context: {effects: {callFn, addCompensation}}}) {
const campaignId = yield callFn(createCampaign, [{name: 'test_campaign'}]);
yield addCompensation<DeleteCampaignPayload>({
topic: topics.DELETE_CAMPAIGN,
payload: {campaign_id: campaignId}
});
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.