Skip to content

Receiver helpers work against a chosen database #367

Description

@bjester

Overview

This task (milestone M2) lets the public receiver helpers run against a database that the caller names. The helpers are buffer validation and the two counter (FSIC) functions.

Background & Motivation

The archive receives records the same way that a network server does. It validates incoming buffers, computes its counters, and updates its counters after dequeue. These helpers are public, and hosts call some of them. Thus each helper needs an optional database parameter. If a caller gives no database, the helper keeps the current behavior.

Design: spec. Plan: implementation plan, Task 6.

Description & Expected Outcomes

Each helper takes db=None. If the caller gives no handle, the helper uses the routed default handle, so existing callers see no change. If the caller gives a handle, all queries and writes in the helper go to that database.

The dequeue function from #366 passes its handle to the counter update.

Deliverables & Contracts

The task delivers an optional db parameter on these helpers:

  • validate_and_create_buffer_data.
  • DatabaseMaxCounter.update_fsics.
  • DatabaseMaxCounter.calculate_filter_specific_instance_counters.

Acceptance Criteria

  • With a handle pinned to default2, buffer validation creates Buffer and RecordMaxCounterBuffer rows in default2 and updates records_transferred.
  • With a handle pinned to default2, the counter update writes DatabaseMaxCounter rows in default2.
  • On an empty default2, the counter calculation for a receiver in v2 format returns an empty result with sub and super keys.
  • No test above makes a query to default.
  • Callers that give no handle see today's behavior.
  • The characterization suite passes without edits.

Technical Pointers & Architecture

  • Target Components: morango/sync/utils.py:72 (validate_and_create_buffer_data), morango/models/core.py:655 (update_fsics), :727 (calculate_filter_specific_instance_counters), and the queries at :690-705, :735, and :775.
  • Related Patterns: SyncDatabase from Explicit database handle for sync database access #365.
  • Data Model & Schema Considerations: None.
  • Resilience & Failure Modes: Validation errors keep their current types.

Notes & Tradeoffs

Metadata

  • Complexity: Medium
  • Target Branch: release-v0.9.x

AI Usage

Drafted with Claude (Claude Code) from the approved design spec and implementation plan. The author reviewed the requirements, and the code references were checked against the release-v0.9.x codebase.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions