Coder Social home page Coder Social logo

temporal-bundle's Introduction

Temporal Bundle

Temporal is the simple, scalable open source way to write and run reliable cloud applications.

Features

  • Sentry: Send throwable events (if the SentryBundle use)
  • Doctrine: clear opened managers and check connection is still usable after each request ( if DoctrineBundle is use)
  • Serializer: Deserialize and serialize messages (if Symfony/Serializer is use, Recommend use)

Requirements:

  • php >= 8.2
  • symfony >= 6.0

Installation:

  1. Connect recipes
composer config --json extra.symfony.endpoint '["https://raw.githubusercontent.com/VantaFinance/temporal-bundle/main/.recipie/index.json", "flex://defaults"]' 
  1. Install package
composer req temporal serializer
  1. Configure docker-compose-temporal.yml/Dockerfile

  2. Added Workflow/Activity. See examples to get started.

Doctrine integrations

If DoctrineBundle is use, the following finalizer is available to you:

  • temporal.doctrine_ping_connection_<entity-mananger-name>.finalizer
  • temporal.doctrine_clear_entity_manager.finalizer

And interceptors:

  • temporal.doctrine_ping_connection_<entity-mananger-name>_activity_inbound.interceptor

Example config:

temporal:
  defaultClient: default
  pool:
    dataConverter: temporal.data_converter
    roadrunnerRPC: '%env(RR_RPC)%'

  workers:
    default:
      taskQueue: default
      exceptionInterceptor: temporal.exception_interceptor
      finalizers: 
        - temporal.doctrine_ping_connection_default.finalizer
        - temporal.doctrine_clear_entity_manager.finalizer
      interceptors:
        - temporal.doctrine_ping_connection_default_activity_inbound.interceptor

  clients:
    default:
      namespace: default
      address: '%env(TEMPORAL_ADDRESS)%'
      dataConverter: temporal.data_converter

Sentry integrations

If SentryBundle is use, the following interceptors is available to you:

  • temporal.sentry_workflow_outbound_calls.interceptor
  • temporal.sentry_activity_inbound.interceptor

Example config:

temporal:
  defaultClient: default
  pool:
    dataConverter: temporal.data_converter
    roadrunnerRPC: '%env(RR_RPC)%'

  workers:
    default:
      taskQueue: default
      exceptionInterceptor: temporal.exception_interceptor
      interceptors:
        - temporal.sentry_workflow_outbound_calls.intercepto
        - temporal.sentry_activity_inbound.interceptor

  clients:
    default:
      namespace: default
      address: '%env(TEMPORAL_ADDRESS)%'
      dataConverter: temporal.data_converter

Assign worker

Running workflows and activities with different task queue Add a AssignWorker attribute to your Workflow or Activity with the name of the worker. This Workflow or Activity will be processed by the specified worker.

Workflow example:

<?php

declare(strict_types=1);

namespace App\Workflow;

use Vanta\Integration\Symfony\Temporal\Attribute\AssignWorker;
use Temporal\Workflow\WorkflowInterface;

#[AssignWorker(name: 'worker1')]
#[WorkflowInterface]
final class MoneyTransferWorkflow
{
    #[WorkflowMethod]
    public function transfer(...): \Generator;

    #[SignalMethod]
    function withdraw(): void;

    #[SignalMethod]
    function deposit(): void;
}

Activity example:

<?php

declare(strict_types=1);

namespace App\Workflow;

use Vanta\Integration\Symfony\Temporal\Attribute\AssignWorker;
use Temporal\Activity\ActivityInterface;
use Temporal\Activity\ActivityMethod;

#[AssignWorker(name: 'worker1')]
#[ActivityInterface(...)]
final class MoneyTransferActivity
{
    #[ActivityMethod]
    public function transfer(...): int;

    #[ActivityMethod]
    public function cancel(...): bool;
}

TODO

  • E2E test
  • documentation

temporal-bundle's People

Contributors

kaspiman avatar root-aza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.