local

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package local is the resource provider a `celerity dev` session runs under.

It is selected by importing it, which `celerity-go generate --local` writes for a development session and never for a deployment:

import _ "github.com/newstack-cloud/celerity-go-sdk/resources/local"
import _ "github.com/newstack-cloud/celerity-go-sdk/resources/local/redis"

What it serves and what it delegates

A queue and a topic, and nothing else. The other four kinds are handed to whichever platform provider is also linked, so a session reaches the emulators that provider was pointed at.

Most of what a session runs speaks the protocol the real service speaks: MinIO answers S3 requests and DynamoDB Local answers DynamoDB's, so a bucket and a data store are reached through the platform's own provider with its endpoint pointed elsewhere. SQS and SNS have no such stand-in, so those two are served locally instead.

Where the serving happens

Not here. This package decides which kinds a session serves and resolves the rest; what carries a local queue or topic is a backend package, linked alongside and registering itself. Today that is resources/local/redis, which this package knows nothing about.

Index

Constants

View Source
const Name = "local"

Name identifies this provider in errors and in the handler manifest.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider serves the resource kinds a development session has to serve itself, and delegates every other kind to the platform's provider.

func New

func New() *Provider

New returns the local resource provider.

An application does not construct one: importing this package registers it. Exported for a test that drives the provider directly.

func (*Provider) Bucket

func (p *Provider) Bucket(ref resources.Ref) (bucket.Store, error)

Bucket hands a bucket to the platform's provider, which a session reaches through the endpoint it was pointed at.

func (*Provider) Cache

func (p *Provider) Cache(ref resources.Ref) (cache.Client, error)

Cache hands a cache to the platform's provider. A cache is the same code on every platform, including the Valkey a session runs, so there is nothing to redirect.

func (*Provider) Close

func (p *Provider) Close(ctx context.Context) error

Close gives back what the linked backends hold, which for a queue and a topic over Redis is the connection they share.

The platform provider's own release is not called from here: both are registered, so the application releases each of them.

func (*Provider) Datastore

func (p *Provider) Datastore(ref resources.Ref) (datastore.Client, error)

Datastore hands a data store to the platform's provider, which a session reaches through the endpoint it was pointed at.

func (*Provider) Detect

func (p *Provider) Detect() bool

Detect reports whether this process is a development session.

The CLI says so explicitly rather than this being inferred: a session's deploy target is still the platform the application will be deployed to, so the platform's own provider is linked alongside. Exactly one of the two detects at a time, whichever order the generated file imports them in.

func (*Provider) Name

func (p *Provider) Name() string

Name identifies the provider.

func (*Provider) Queue

func (p *Provider) Queue(ref resources.Ref) (queue.Client, error)

Queue returns a handle to whatever the session runs in place of a queue.

func (*Provider) SQLDatabase

func (p *Provider) SQLDatabase(ref resources.Ref) (sqldb.Client, error)

SQLDatabase hands a database to the platform's provider, which a session points at whatever it runs.

func (*Provider) Topic

func (p *Provider) Topic(ref resources.Ref) (topic.Client, error)

Topic returns a handle to whatever the session runs in place of a topic.

Directories

Path Synopsis
internal
backend
Package backend is the seam between the local provider and what actually serves a resource in a development session.
Package backend is the seam between the local provider and what actually serves a resource in a development session.

Jump to

Keyboard shortcuts

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