Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Microsoft Open Source Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).

Resources:

- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
- Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributing

This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (for example, label or comment).
Simply follow the instructions provided by the bot. You will only need to do this once
across all repositories using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Reporting security issues

Please do not report security vulnerabilities through public GitHub issues. Follow the instructions in [SECURITY.md](SECURITY.md).

## Development workflow

Before opening a pull request, run the checks relevant to your change:

```bash
cargo nextest run
cargo clippy --all-targets
```

If `cargo-nextest` is not available, use `cargo test` as a fallback. PostgreSQL-backed tests require `DATABASE_URL` to point to a test database.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@ Two test layers cover the Entra integration:

- Fix: add `native-tls` feature to the `reqwest` dependency so HTTPS calls compiled into the crate (including AAD token acquisition for `connectWithEntra` / `connectWithSchemaAndEntra`) work end-to-end. Prior 0.1.32 binaries failed with `error sending request` / `invalid URL, scheme is not http` whenever Entra auth was used.

## Support

Use GitHub Issues for bug reports and feature requests. Do not report security vulnerabilities through public GitHub issues; follow the instructions in [SECURITY.md](SECURITY.md) instead.

## Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or comments.

## Security

Microsoft takes the security of our software products and services seriously. Please do not report security vulnerabilities through public GitHub issues. See [SECURITY.md](SECURITY.md) for security reporting instructions.

## Privacy and Telemetry

duroxide-pg does not send telemetry to Microsoft. Applications may configure their own database, logging, or metrics collection; those signals are controlled by the application owner.

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos is subject to those third-party policies.

## License

MIT License - see [LICENSE](LICENSE) for details.
3 changes: 3 additions & 0 deletions migrations/0001_initial_schema.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0001_initial_schema.sql
-- Description: Creates initial schema for Duroxide PostgreSQL provider
-- This migration will be executed with schema-qualified names via the migration runner
Expand Down
3 changes: 3 additions & 0 deletions migrations/0002_create_stored_procedures.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration 0002: Create stored procedures for PostgreSQL provider
-- This migration creates schema-qualified stored procedures to replace inline SQL queries
-- Note: This migration runs with SET LOCAL search_path TO {schema_name}, so procedures
Expand Down
3 changes: 3 additions & 0 deletions migrations/0003_add_attempt_count.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0003_add_attempt_count.sql
-- Description: Adds attempt_count column for poison message detection (duroxide 0.1.2)
-- This column tracks how many times a message has been fetched for processing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0004_update_stored_procedures_for_attempt_count.sql
-- Description: Updates stored procedures to support attempt_count for poison message detection
-- This migration updates procedures that were created in 0002 to work with the attempt_count
Expand Down
3 changes: 3 additions & 0 deletions migrations/0005_add_visible_at_to_worker_queue.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0005_add_visible_at_to_worker_queue.sql
-- Description: Adds visible_at column to worker_queue for delayed visibility (duroxide 0.1.5)
-- This provides consistent visibility semantics between orchestrator_queue and worker_queue.
Expand Down
3 changes: 3 additions & 0 deletions migrations/0006_use_rust_timestamps.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0006_use_rust_timestamps.sql
-- Description: Updates all stored procedures to use Rust-provided timestamps (p_now_ms)
-- instead of database NOW(). This ensures consistent time handling between the application
Expand Down
3 changes: 3 additions & 0 deletions migrations/0007_add_execution_state_support.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0007_add_execution_state_support.sql
-- Description: Updates fetch_work_item and renew_work_item_lock to return ExecutionState
-- Required for duroxide 0.1.7 activity cancellation support
Expand Down
3 changes: 3 additions & 0 deletions migrations/0008_remove_execution_state.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0008_remove_execution_state.sql
-- Description: Removes ExecutionState from fetch_work_item and renew_work_item_lock
-- Required for duroxide main branch which removed ExecutionState from provider API
Expand Down
3 changes: 3 additions & 0 deletions migrations/0009_add_activity_cancellation_support.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0009_add_activity_cancellation_support.sql
-- Description: Adds support for activity cancellation via lock stealing
-- Required for duroxide main branch which adds cancelled_activities to ack_orchestration_item
Expand Down
3 changes: 3 additions & 0 deletions migrations/0010_add_deletion_and_pruning_support.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration 0010: Add deletion and pruning support
-- This migration adds:
-- 1. parent_instance_id column to instances table (for cascade deletion)
Expand Down
3 changes: 3 additions & 0 deletions migrations/0011_fix_cancellation_ordering.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0011_fix_cancellation_ordering.sql
-- Description: Fixes the ordering of operations in ack_orchestration_item
-- Required for duroxide 0.1.15 test: test_same_activity_in_worker_items_and_cancelled_is_noop
Expand Down
3 changes: 3 additions & 0 deletions migrations/0012_require_timestamps.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0012_require_timestamps.sql
-- Description: Aligns timestamp handling with duroxide-pg-opt.
-- Stored procedure now accepts p_now_ms from Rust (app-server clock)
Expand Down
3 changes: 3 additions & 0 deletions migrations/0013_add_capability_filtering.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0013_add_capability_filtering.sql
-- Description: Adds capability filtering support for provider-level version matching.
-- Adds duroxide_version columns to executions table, updates fetch_orchestration_item
Expand Down
3 changes: 3 additions & 0 deletions migrations/0014_add_session_support.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0014_add_session_support.sql
-- Description: Adds session affinity support for worker queue items.
-- Creates sessions table, adds session_id column to worker_queue,
Expand Down
3 changes: 3 additions & 0 deletions migrations/0015_add_custom_status.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0015_add_custom_status.sql
-- Description: Adds custom status support for orchestration instances.
-- Adds custom_status and custom_status_version columns to instances table,
Expand Down
3 changes: 3 additions & 0 deletions migrations/0016_add_activity_tags.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration: 0016_add_activity_tags.sql
-- Description: Adds activity tag routing support for worker queue items.
-- Adds tag column to worker_queue, updates enqueue_worker_work to accept tag,
Expand Down
3 changes: 3 additions & 0 deletions migrations/0017_retry_orchestration_fetch_on_contention.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration 0017: Retry orchestration fetch on contention
-- Description: Updates fetch_orchestration_item to continue searching for
-- another eligible instance when the initially selected instance becomes locked
Expand Down
3 changes: 3 additions & 0 deletions migrations/0018_add_kv_store.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration 0018: Add KV store support
-- Description: Adds a durable per-instance KV store, returns KV snapshots during orchestration fetch,
-- materializes KV mutations during ack, and cleans up KV state during deletion/pruning.
Expand Down
3 changes: 3 additions & 0 deletions migrations/0019_add_kv_last_updated.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration 0019: Add KV last-updated timestamps
-- Description: Adds per-key last_updated_at_ms tracking, returns timestamped KV snapshots,
-- materializes KV timestamps during ack, and preserves KV state across execution pruning.
Expand Down
3 changes: 3 additions & 0 deletions migrations/0020_add_kv_delta.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration 0020: Add KV delta table
-- Description: Captures current-execution KV mutations in kv_delta, merges them into
-- kv_store only at execution completion boundaries, and cleans up delta rows on deletion.
Expand Down
3 changes: 3 additions & 0 deletions migrations/0021_add_get_instance_stats.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Copyright (c) Microsoft Corporation.
-- Licensed under the MIT License.

-- Migration 0021: Add get_instance_stats stored procedure
-- Description: Moves the inline get_instance_stats queries into a single stored procedure,
-- consolidating four round trips into one and correctly merging kv_delta + kv_store counts.
Expand Down
3 changes: 3 additions & 0 deletions pg-stress/src/bin/pg-stress.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use clap::Parser;
use duroxide_pg_stress::run_test_suite;
use tracing_subscriber::EnvFilter;
Expand Down
3 changes: 3 additions & 0 deletions pg-stress/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! PostgreSQL Provider Stress Tests for Duroxide
//!
//! This library provides PostgreSQL-specific stress test implementations for Duroxide,
Expand Down
3 changes: 3 additions & 0 deletions scripts/cleanup_test_schemas.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Clean up all test schemas from the PostgreSQL database
# Usage: ./scripts/cleanup_test_schemas.sh

Expand Down
3 changes: 3 additions & 0 deletions scripts/generate_migration_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Generate per-function migration diff with full context."""
import subprocess, sys, os, tempfile, textwrap

Expand Down
3 changes: 3 additions & 0 deletions scripts/generate_migration_diff.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Generate a per-function diff markdown file for a specific migration.
# Usage: ./scripts/generate_migration_diff.sh <migration_number>
# Example: ./scripts/generate_migration_diff.sh 9
Expand Down
3 changes: 3 additions & 0 deletions scripts/measure-server-performance.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Measure server-side performance using pg_stat_statements
# This script runs stress tests and compares server execution time vs network RTT

Expand Down
3 changes: 3 additions & 0 deletions scripts/provision_entra_ci_pg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# One-time provisioning for the Entra-auth live test in GitHub Actions CI.
#
# What this creates (idempotent — safe to re-run):
Expand Down
3 changes: 3 additions & 0 deletions scripts/provision_entra_test_pg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Provision an Azure Database for PostgreSQL Flexible Server suitable for
# running `tests/entra_live_test.rs`.
#
Expand Down
3 changes: 3 additions & 0 deletions scripts/start-measurement.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Start performance measurement by resetting pg_stat_statements

set -e
Expand Down
3 changes: 3 additions & 0 deletions scripts/stop-measurement.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Stop performance measurement and display pg_stat_statements results

set -e
Expand Down
3 changes: 3 additions & 0 deletions scripts/teardown_entra_ci_pg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Tear down the resources created by `provision_entra_ci_pg.sh`.
#
# Deletes:
Expand Down
3 changes: 3 additions & 0 deletions scripts/teardown_entra_test_pg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Tear down the resource group created by `provision_entra_test_pg.sh`.
#
# Uses the same naming convention as the provision script. Override
Expand Down
3 changes: 3 additions & 0 deletions src/entra.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Microsoft Entra ID (formerly Azure Active Directory) authentication support
//! for [`PostgresProvider`](crate::PostgresProvider).
//!
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! # Duroxide PostgreSQL Provider
//!
//! A PostgreSQL-based provider implementation for [Duroxide](https://crates.io/crates/duroxide),
Expand Down
3 changes: 3 additions & 0 deletions src/migrations.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use anyhow::Result;
use include_dir::{include_dir, Dir};
use sqlx::Connection;
Expand Down
3 changes: 3 additions & 0 deletions src/provider.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use anyhow::{Context, Result};
use chrono::{TimeZone, Utc};
use duroxide::providers::{
Expand Down
3 changes: 3 additions & 0 deletions tests/basic_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use duroxide::providers::{ExecutionMetadata, Provider, TagFilter, WorkItem};
use duroxide::{Event, EventKind, INITIAL_EVENT_ID, INITIAL_EXECUTION_ID};
use duroxide_pg::PostgresProvider;
Expand Down
3 changes: 3 additions & 0 deletions tests/cached_plan_retryable_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Tests that `cached plan must not change result type` (SQLSTATE 0A000) is
//! handled as a retryable error, allowing transparent recovery when a stored
//! procedure is replaced by a concurrent migration.
Expand Down
3 changes: 3 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use duroxide::providers::{ExecutionMetadata, Provider, WorkItem};
use duroxide::{Event, EventKind};
use duroxide_pg::PostgresProvider;
Expand Down
3 changes: 3 additions & 0 deletions tests/concurrent_migration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Repro for https://github.com/microsoft/duroxide/issues/10
//!
//! When multiple workers start simultaneously against a fresh database,
Expand Down
3 changes: 3 additions & 0 deletions tests/continue_as_new_stress_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Stress tests for continue-as-new functionality with PostgreSQL provider
//!
//! These tests verify that long-running orchestrations using continue-as-new
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e_samples.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! End-to-end samples: start here to learn the API by example.
//!
//! Each test demonstrates a common orchestration pattern using
Expand Down
3 changes: 3 additions & 0 deletions tests/entra_live_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Live Entra ID smoke test against a real Azure Database for PostgreSQL.
//!
//! This test is `#[ignore]` by default and is opt-in via the
Expand Down
3 changes: 3 additions & 0 deletions tests/migration_policy_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Tests for [`MigrationPolicy`] / [`ProviderConfig`] / `new_with_config`.
//!
//! These tests verify that:
Expand Down
Loading
Loading