Data source and sink connectors¶
Audience: Engineers moving files between object storage (Amazon S3, Google Cloud Storage, or any other object store) and capsules. Time to read: 7 minutes. Prerequisites: A Nanorix API key, a finalized Capsulefile, and the Python SDK 0.7.0 or later.
Connectors remove the boilerplate of wiring object storage to capsules.
Instead of hand-writing a read-from-S3 → capsule.upload() loop and a
capsule.download() → write-to-S3 loop, you point a source at your
input bucket and a sink at your output bucket. The capsule does the
work in between, and produces an AuditProof as always.
Where regulated data runs. Production regulated data runs only in a Nanorix deployment you run yourself. The hosted endpoint at nanorix.io is an evaluation sandbox for synthetic data, with no regulated data. Samples below that handle regulated data show
base_urlpointing at your own deployment.
The trust boundary — read this first¶
A Nanorix connector is a customer-side SDK helper. It is not a Nanorix-hosted ingestion service. Concretely:
- Your bytes. The connector reads each object from your storage in bounded chunks, holds that one object in your process's memory, and uploads it to the sealed capsule over TLS as one file. The API holds the file in memory only while it writes it into the capsule's memory-only filesystem. Nanorix never stages your data: nothing is spooled to disk or written to a temporary file on the way.
- Your credentials. The connector runs in your process and resolves credentials through the cloud SDK's standard chain (environment variables, instance profile, workload identity). Nanorix never takes custody of your cloud credentials and the connector object retains no secret.
- Streamed through the sealed capsule. A source streams INTO the capsule before it executes. A sink streams the capsule's output to your destination before the capsule is destroyed — never after. Once the AuditProof says the capsule is destroyed, there is, by design, no capsule data left to read.
- No new claim. A connector moves bytes. It makes no statement about what the data is or which control it relates to. The AuditProof's claim is unchanged — connectors add convenience, not claim surface.
In one line: your bytes, your creds, streamed through the sealed capsule, never staged on Nanorix.
Install¶
Connectors live behind optional extras so the base SDK stays lean:
pip install nanorix[s3] # Amazon S3 (boto3)
pip install nanorix[gcs] # Google Cloud Storage (google-cloud-storage)
The framework-agnostic streaming core (nanorix.connectors) imports
without any cloud SDK; only the cloud-specific connector classes need the
extra. Importing nanorix.connectors.s3 without boto3 installed raises a
clear, actionable error pointing you at pip install nanorix[s3].
S3 source → capsule → S3 sink¶
from nanorix import Client
from nanorix.connectors import stream_source_into_capsule, stream_capsule_to_sink
from nanorix.connectors.s3 import S3Source, S3Sink
client = Client(
api_key="nrx_live_...",
base_url="https://nanorix.internal.example.com", # your own deployment
)
# You declare the buckets and prefixes; Nanorix never infers them.
# Credentials come from boto3's standard chain in YOUR process —
# Nanorix never sees them.
source = S3Source(bucket="my-input-bucket", prefix="incoming/")
sink = S3Sink(bucket="my-output-bucket", prefix="processed/")
capsule = client.capsules.create(capsulefile="cf_my_workload")
# 1. Stream the input objects INTO the capsule (before exec).
stream_source_into_capsule(client, capsule, source)
# 2. Run your workload.
capsule.execute()
# 3. Stream the capsule output to your destination (BEFORE destroy).
stream_capsule_to_sink(client, capsule, ["result.json"], sink)
# 4. Destroy → AuditProof.
audit_proof = capsule.destroy()
With the orchestrator core (Airflow / Temporal / Dagster / …)¶
The orchestrator core (run_capsule_job) drives connectors when
you declare sources / sinks on the job params. Source-stream happens
before exec; sink-stream happens before destroy; the lifecycle is the
same one the operators use.
from nanorix import Client
from nanorix.integrations import CapsuleJobParams, run_capsule_job
from nanorix.connectors.s3 import S3Source, S3Sink
params = CapsuleJobParams(
capsulefile="cf_my_workload",
sources=[S3Source(bucket="my-input-bucket", prefix="incoming/")],
output_files=["result.json"],
sinks=[S3Sink(bucket="my-output-bucket", prefix="processed/")],
data_classification="PHI", # you declare this; Nanorix records it, lowercased, as declared
)
result = run_capsule_job(client, params)
audit_proof = result.audit_proof # the same AuditProof, unchanged
sources and sinks are optional and backward-compatible: jobs that
declare neither behave exactly as before.
Google Cloud Storage¶
Identical shape, GCS classes:
from nanorix.connectors.gcs import GCSSource, GCSSink
source = GCSSource(bucket="my-input-bucket", prefix="incoming/")
sink = GCSSink(bucket="my-output-bucket", prefix="processed/")
Credentials resolve through Application Default Credentials
(GOOGLE_APPLICATION_CREDENTIALS, gcloud auth, workload identity) in
your process. Same trust boundary: Nanorix never holds them.
Bounded reads, whole-file uploads¶
Reads are chunked: the connector asks your store for at most one configurable chunk at a time (default 8 MiB). The SDK's upload and download calls take whole files, so each object is held whole in your process's memory while it is uploaded, one object at a time. On the way out, each capsule output is downloaded whole and handed to the sink in chunks. An object larger than the capsule's per-file upload limit is refused. You can raise the read chunk:
or, with the orchestrator core, CapsuleJobParams(..., connector_chunk_size=...).
Other object stores — same pattern¶
Azure Blob Storage, MinIO, Cloudflare R2, and any other object store
follow the same Source / Sink protocols. They are documentation,
not new engines. To wire one, implement two methods:
from typing import Iterator
from nanorix.connectors import Source, Sink, SourceObject
class AzureBlobSource(Source):
def __init__(self, container: str, prefix: str = "", *, client=None):
# credentials resolve through azure-identity's DefaultAzureCredential
# in YOUR process — Nanorix never holds them.
...
def list_objects(self): # -> Iterable[SourceObject]
...
def open_object(self, obj: SourceObject, chunk_size: int) -> Iterator[bytes]:
# yield at most chunk_size bytes per chunk — never the whole object
...
class AzureBlobSink(Sink):
def write_object(self, capsule_filename: str, chunks: Iterator[bytes]) -> str:
# stream chunk-by-chunk to the destination; return the dest key
...
The streaming core enforces the trust boundary regardless of the backend: bounded reads, one object at a time, source-before-exec, sink-before-destroy, no Nanorix staging.
What connectors are NOT for: long-lived streams¶
Connectors handle object-storage batch ingest/egress and bounded pulls — a finite, capsule-shaped unit of work. They are deliberately not Kafka / Kinesis / Pub/Sub consumers. A standing stream subscription has no natural capsule boundary and would require persistent state (consumer offsets, an open connection) that contradicts the ephemeral capsule model.
The idiomatic Nanorix answer for streaming is per-message or micro-batch capsules: your own consumer (a Lambda, a Kafka Streams app, a Flink job, a Cloud Function) receives a message or a bounded micro-batch and spins one capsule per message / per micro-batch, each producing its own AuditProof.
# Your Kafka consumer loop — NOT a Nanorix connector:
for message in consumer: # your code, your offsets
result = run_capsule_job(client, CapsuleJobParams(
capsulefile="cf_my_workload",
input_files={"event.json": message.value},
output_files=["result.json"],
))
publish(result.outputs["result.json"]) # one AuditProof per message
consumer.commit()
This keeps each capsule sealed, ephemeral, and individually provable — which is the whole point.