ydb

package module
v0.0.0-...-c138e03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

RoadRunner YDB Plugin

A plugin for RoadRunner that provides integration with YDB (Yandex Database) for job queue functionality.

Overview

This plugin allows PHP applications using RoadRunner to use YDB as a backend for job queues. It implements the RoadRunner jobs API and provides a driver for YDB's topic service, enabling message-based job processing with YDB.

Features

  • Push jobs to YDB topics
  • Consume jobs from YDB topics
  • Pause and resume job processing
  • Configure job priorities
  • Secure connections with TLS
  • Authentication with static credentials

Requirements

  • Go 1.24 or higher
  • RoadRunner v2024.2.0 or higher
  • YDB instance

Configuration

Add the following to your .rr.yaml configuration file:

ydb:
  endpoint: "grpcs://ydb.serverless.yandexcloud.net:2135"
  static_credentials:
    user: "your-user"
    password: "your-password"
  tls:
    ca: "/path/to/ca.crt"

jobs:
  pipelines:
    example:
      driver: ydb
      topic: "your-topic"
      priority: 10
      producer_options:
        id: "producer-id"
      consumer_options:
        name: "consumer-name"
Configuration Options
Global Options
Option Description Default
endpoint YDB endpoint URL Required
static_credentials.user Username for authentication Optional
static_credentials.password Password for authentication Optional
tls.ca Path to CA certificate for TLS Optional
Pipeline Options
Option Description Default
topic YDB topic name Required
priority Job priority 10
producer_options.id Producer ID Generated
consumer_options.name Consumer name Generated

Usage

Pushing Jobs
use Spiral\RoadRunner\Jobs\Jobs;

$jobs = new Jobs();
$queue = $jobs->connect('example');

$queue->push(
    'job-name',
    ['data' => 'value'],
    [
        'topic' => 'your-topic',
        'priority' => 1,
    ]
);
Processing Jobs
use Spiral\RoadRunner\Jobs\Consumer;
use Spiral\RoadRunner\Jobs\Jobs;

$jobs = new Jobs();
$consumer = new Consumer();

while ($job = $consumer->waitJob()) {
    try {
        // Process job
        $payload = $job->getPayload();
        // Your job handling logic here
        
        $job->complete();
    } catch (\Throwable $e) {
        $job->fail($e);
    }
}

Testing

The plugin includes integration tests that verify its functionality with YDB. To run the tests:

  1. Make sure you have a YDB instance available for testing
  2. Configure the test environment in tests/configs/.rr-init.yaml
  3. Run the tests:
go test -v ./tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configurer

type Configurer interface {
	UnmarshalKey(name string, out any) error
	Has(name string) bool
}

type Logger

type Logger interface {
	NamedLogger(name string) *zap.Logger
}

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func (*Plugin) DriverFromConfig

func (p *Plugin) DriverFromConfig(configKey string, queue jobs.Queue, pipeline jobs.Pipeline) (jobs.Driver, error)

func (*Plugin) DriverFromPipeline

func (p *Plugin) DriverFromPipeline(pipeline jobs.Pipeline, queue jobs.Queue) (jobs.Driver, error)

func (*Plugin) Init

func (p *Plugin) Init(log Logger, cfg Configurer) error

func (*Plugin) Name

func (p *Plugin) Name() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址