ocinosql

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 37 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

OCI NoSQL Database Cloud Service

Parity grade: B · SDK github.com/oracle/oci-go-sdk/v65@v65.126.2 · last audited 2026-10-29 (57ea757db)

Coverage

Metric Value
PARITY entries audited 27 (22 ok, 5 partial)
Feature families 9 (6 ok, 3 partial)
Known gaps 2
Deferred items 0
Resource leaks unknown
Known gaps
  • The storage quota (maxStorageInGBs) is not enforced and storageThrottleCount stays 0: the smallest quota is 1 GB (tables.go:77), so a write rejected for exceeding it cannot be exercised without storing over 1 GiB of rows.
  • IAM policy checks, resource principals and instance principals are not applied; only API-key signatures are verified.

More

Documentation

Index

Constants

View Source
const DefaultPort = 8162

DefaultPort is the dedicated listener's default TCP port.

View Source
const (
	// Region is the fixed region baked into emulated OCIDs.
	Region = "us-ashburn-1"
)

Variables

View Source
var ErrNilAppContext = errors.New("ocinosql: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

View Source
var ErrSnapshotNull = errors.New("ocinosql: null entry in snapshot")

ErrSnapshotNull is returned when a snapshot contains a null entry.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    string
	Message string
	Status  int
}

APIError is an OCI error response: HTTP status plus the `code` and `message` body fields.

func (*APIError) Error

func (e *APIError) Error() string

type Column

type Column struct {
	Name    string         `json:"name"`
	Type    string         `json:"type"`
	Default jsontext.Value `json:"default,omitempty"`
	NotNull bool           `json:"notNull,omitempty"`
	AsUUID  bool           `json:"asUuid,omitempty"`
	Gen     bool           `json:"generated,omitempty"`
}

Column is one table column.

type ConfigProvider

type ConfigProvider interface {
	GetOCINoSQLSettings() Settings
}

ConfigProvider extracts OCI NoSQL configuration from the AppContext Config.

type Configuration

type Configuration struct {
	KmsCreated   *time.Time `json:"kmsCreated,omitempty"`
	KmsUpdated   *time.Time `json:"kmsUpdated,omitempty"`
	TransitionAt *time.Time `json:"transitionAt,omitempty"`
	KmsKeyID     string     `json:"kmsKeyId,omitempty"`
	KmsVaultID   string     `json:"kmsVaultId,omitempty"`
	KmsState     string     `json:"kmsState"`
	Etag         string     `json:"etag"`
}

Configuration is the service-level configuration of a hosted environment.

type ConfigurationWire

type ConfigurationWire struct {
	KmsKey      *kmsKeyWire `json:"kmsKey,omitempty"`
	Environment string      `json:"environment"`
}

ConfigurationWire is the wire form of GetConfiguration.

type DeleteRowResult

type DeleteRowResult struct {
	ExistingVersion *string        `json:"existingVersion,omitempty"`
	ExistingValue   jsontext.Value `json:"existingValue,omitempty"`
	IsSuccess       bool           `json:"isSuccess"`
	Usage           usageWire      `json:"usage"`
}

DeleteRowResult is the DeleteRow response body.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Port        int
	EnforceAuth bool
	// contains filtered or unexported fields
}

Handler serves OCI NoSQL Database: tables, indexes, rows, queries and work requests.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a Handler; callers override Port and EnforceAuth from Settings.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name for metrics.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the addressed resource id for metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler for all OCINoSQL requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all in-memory state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: OCINoSQL runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the listener and the sweeper.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the dedicated listener synchronously so a port conflict is returned to the caller.

func (*Handler) Trusted

func (h *Handler) Trusted() echo.HandlerFunc

Trusted returns a handler that skips request-signature verification, for the in-process dashboard proxy.

type Identity

type Identity struct {
	Column    string `json:"column"`
	Always    bool   `json:"always"`
	OnNull    bool   `json:"onNull,omitempty"`
	Next      int64  `json:"next"`
	Increment int64  `json:"increment"`
}

Identity is the table's identity column spec and its counter.

type InMemoryBackend

type InMemoryBackend struct {
	Auth *ociauth.Registry
	// contains filtered or unexported fields
}

InMemoryBackend holds every table and work request under one lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) ChangeTableCompartment

func (b *InMemoryBackend) ChangeTableCompartment(ref, ifMatch string, in changeCompartmentIn) (string, error)

ChangeTableCompartment moves a table to another compartment.

func (*InMemoryBackend) Compartments

func (b *InMemoryBackend) Compartments() []string

Compartments lists the distinct compartments that hold tables.

func (*InMemoryBackend) CreateIndex

func (b *InMemoryBackend) CreateIndex(ref string, in createIndexIn) (string, error)

CreateIndex adds a secondary index to a table and returns its work request id.

func (*InMemoryBackend) CreateReplica

func (b *InMemoryBackend) CreateReplica(ref, ifMatch string, in replicaIn) (string, error)

CreateReplica records a replica of a table in a remote region and returns its work request id.

func (*InMemoryBackend) CreateTable

func (b *InMemoryBackend) CreateTable(in createTableIn) (string, error)

CreateTable creates a table from a CREATE TABLE statement and returns its work request id.

func (*InMemoryBackend) DeleteIndex

func (b *InMemoryBackend) DeleteIndex(ref, name, compartment string, ifExists bool) (string, error)

DeleteIndex removes an index; ifExists turns a missing index into a no-op (empty work request id).

func (*InMemoryBackend) DeleteReplica

func (b *InMemoryBackend) DeleteReplica(ref, region, compartment, ifMatch string) (string, error)

DeleteReplica removes the replica in a region and returns its work request id.

func (*InMemoryBackend) DeleteRow

func (b *InMemoryBackend) DeleteRow(
	ref, compartment string,
	key []string,
	ifMatch string,
	returnRow bool,
) (DeleteRowResult, error)

DeleteRow removes one row by primary key.

func (*InMemoryBackend) DeleteTable

func (b *InMemoryBackend) DeleteTable(ref, compartment, ifMatch string, ifExists bool) (string, error)

DeleteTable drops a table; ifExists turns a missing table into a no-op (empty work request id).

func (*InMemoryBackend) DeleteWorkRequest

func (b *InMemoryBackend) DeleteWorkRequest(id, ifMatch string) (string, error)

DeleteWorkRequest cancels an unfinished work request; the resource transition it describes still completes.

func (*InMemoryBackend) GetConfiguration

func (b *InMemoryBackend) GetConfiguration(compartment string) (ConfigurationWire, string, error)

GetConfiguration returns the service-level configuration and its etag.

func (*InMemoryBackend) GetIndex

func (b *InMemoryBackend) GetIndex(ref, name, compartment string) (IndexWire, error)

GetIndex returns one index.

func (*InMemoryBackend) GetRow

func (b *InMemoryBackend) GetRow(ref, compartment string, key []string, consistency string) (RowResult, string, error)

GetRow reads one row by primary key.

func (*InMemoryBackend) GetTable

func (b *InMemoryBackend) GetTable(ref, compartment string) (TableWire, string, error)

GetTable returns one table and its etag.

func (*InMemoryBackend) GetWorkRequest

func (b *InMemoryBackend) GetWorkRequest(id string) (WorkRequestWire, error)

GetWorkRequest returns one work request.

func (*InMemoryBackend) ListIndexes

func (b *InMemoryBackend) ListIndexes(ref, compartment, name, state string, o ListOpts) (page.Page[IndexWire], error)

ListIndexes lists the indexes of a table.

func (*InMemoryBackend) ListTableUsage

func (b *InMemoryBackend) ListTableUsage(
	ref, compartment, start, end string,
	o ListOpts,
) (page.Page[UsageWire], error)

ListTableUsage reports per-minute consumption recorded for a table.

func (*InMemoryBackend) ListTables

func (b *InMemoryBackend) ListTables(
	compartment, name, state string,
	o ListOpts,
) (page.Page[TableWire], TableList, error)

ListTables lists tables of a compartment.

func (*InMemoryBackend) ListWorkRequests

func (b *InMemoryBackend) ListWorkRequests(compartment string, o ListOpts) (page.Page[WorkRequestWire], error)

ListWorkRequests lists the work requests of a compartment, optionally for one resource.

func (*InMemoryBackend) PrepareStatement

func (b *InMemoryBackend) PrepareStatement(compartment, statement string, withPlan bool) (PreparedStatement, error)

PrepareStatement validates a SELECT against its table and returns an opaque prepared form.

func (*InMemoryBackend) Query

func (b *InMemoryBackend) Query(in queryIn, limit int, token string) (page.Page[map[string]any], usageWire, error)

Query runs a SELECT statement and returns one page of results.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a snapshot.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock injects the time source used for lifecycle transitions and TTL expiry.

func (*InMemoryBackend) SetCompartmentChecker

func (b *InMemoryBackend) SetCompartmentChecker(fn func(string) bool)

SetCompartmentChecker validates compartmentId arguments against another service (OCI Identity).

func (*InMemoryBackend) SetEnforceThroughput

func (b *InMemoryBackend) SetEnforceThroughput(on bool)

SetEnforceThroughput turns on 429 throttling of PROVISIONED tables once a second's units are spent.

func (*InMemoryBackend) SetMultiTenancy

func (b *InMemoryBackend) SetMultiTenancy(on bool)

SetMultiTenancy switches the emulated environment between HOSTED (default) and MULTI_TENANCY.

func (*InMemoryBackend) SetTagLookup

func (b *InMemoryBackend) SetTagLookup(fn ocitags.Lookup)

SetTagLookup wires defined-tag validation against a tag namespace source (OCI Identity); nil accepts any namespace.

func (*InMemoryBackend) SetTransition

func (b *InMemoryBackend) SetTransition(d time.Duration)

SetTransition sets how long CREATING, UPDATING and DELETING states last.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state, including registered API keys.

func (*InMemoryBackend) SummarizeStatement

func (b *InMemoryBackend) SummarizeStatement(compartment, statement string) (StatementSummary, error)

SummarizeStatement classifies a statement and reports syntax errors without executing anything.

func (*InMemoryBackend) Sweep

func (b *InMemoryBackend) Sweep()

Sweep applies lifecycle transitions against the backend clock.

func (*InMemoryBackend) SweepRows

func (b *InMemoryBackend) SweepRows()

SweepRows removes expired rows from every table.

func (*InMemoryBackend) UnassignKmsKey

func (b *InMemoryBackend) UnassignKmsKey(compartment, ifMatch string, dryRun bool) (string, error)

UnassignKmsKey reverts to Oracle-managed encryption; with no key assigned it only records a work request.

func (*InMemoryBackend) UpdateConfiguration

func (b *InMemoryBackend) UpdateConfiguration(
	compartment, ifMatch string,
	dryRun bool,
	in updateConfigIn,
) (string, error)

UpdateConfiguration assigns the global KMS key; a dry run validates only and returns no work request.

func (*InMemoryBackend) UpdateRow

func (b *InMemoryBackend) UpdateRow(ref, ifMatch string, in updateRowIn) (UpdateRowResult, error)

UpdateRow puts a row into a table.

func (*InMemoryBackend) UpdateTable

func (b *InMemoryBackend) UpdateTable(ref, ifMatch string, in updateTableIn) (string, error)

UpdateTable alters a table's schema, limits or tags.

func (*InMemoryBackend) WorkRequestExists

func (b *InMemoryBackend) WorkRequestExists(id string) error

WorkRequestExists reports whether a work request exists (its error list is always empty).

func (*InMemoryBackend) WorkRequestLogs

func (b *InMemoryBackend) WorkRequestLogs(id string, o ListOpts) (page.Page[wrLogWire], error)

WorkRequestLogs returns the log entries of a work request.

type Index

type Index struct {
	Created      time.Time  `json:"created"`
	TransitionAt *time.Time `json:"transitionAt,omitempty"`
	Name         string     `json:"name"`
	State        string     `json:"state"`
	Keys         []IndexKey `json:"keys"`
}

Index is a secondary index on a table.

type IndexKey

type IndexKey struct {
	Column   string `json:"column"`
	JSONPath string `json:"jsonPath,omitempty"`
	JSONType string `json:"jsonType,omitempty"`
}

IndexKey is one key of a secondary index.

type IndexWire

type IndexWire struct {
	Name           string         `json:"name"`
	CompartmentID  string         `json:"compartmentId,omitempty"`
	TableName      string         `json:"tableName,omitempty"`
	TableID        string         `json:"tableId,omitempty"`
	LifecycleState string         `json:"lifecycleState"`
	Keys           []indexKeyWire `json:"keys"`
}

IndexWire is the full index representation.

type Limits

type Limits struct {
	Mode       string `json:"mode"`
	ReadUnits  int    `json:"readUnits"`
	WriteUnits int    `json:"writeUnits"`
	StorageGB  int    `json:"storageGb"`
}

Limits are a table's throughput and storage limits.

type ListOpts

type ListOpts struct {
	SortBy string
	Order  string
	Page   string
	Limit  int
}

ListOpts carries the shared list query parameters.

type PreparedStatement

type PreparedStatement struct {
	QueryPlan any       `json:"queryPlan,omitempty"`
	Statement string    `json:"statement"`
	Usage     usageWire `json:"usage"`
}

PreparedStatement is the PrepareStatement response body.

type Provider

type Provider struct{}

Provider implements service.Provider for OCI NoSQL. It runs on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.

func (*Provider) Init

Init creates the backend and handler; the port is bound in StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type QueryResult

type QueryResult struct {
	Items []map[string]any `json:"items"`
	Usage usageWire        `json:"usage"`
}

QueryResult is the Query response body.

type Replica

type Replica struct {
	TransitionAt *time.Time `json:"transitionAt,omitempty"`
	Region       string     `json:"region"`
	TableID      string     `json:"tableId"`
	Mode         string     `json:"mode"`
	State        string     `json:"state"`
	WriteUnits   int        `json:"writeUnits"`
}

Replica is a remote-region copy of a table; the emulator records its metadata only.

type Row

type Row struct {
	Expire  *time.Time     `json:"expire,omitempty"`
	Version string         `json:"version"`
	Value   jsontext.Value `json:"value"`
}

Row is one stored table row.

type RowResult

type RowResult struct {
	TimeOfExpiration *time.Time     `json:"timeOfExpiration,omitempty"`
	Value            jsontext.Value `json:"value"`
	Usage            usageWire      `json:"usage"`
}

RowResult is the GetRow response body.

type Settings

type Settings struct {
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 187-byte string literal not displayed */
	EnforceAuth bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 221-byte string literal not displayed */

	EnforceThroughput bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 271-byte string literal not displayed */
}

Settings holds service-level configuration, embedded in the root CLI as CLI.OCINoSQL.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider is available.

type StatementSummary

type StatementSummary struct {
	SyntaxError   *string `json:"syntaxError,omitempty"`
	Operation     string  `json:"operation,omitempty"`
	TableName     string  `json:"tableName,omitempty"`
	IndexName     string  `json:"indexName,omitempty"`
	IsIfExists    bool    `json:"isIfExists"`
	IsIfNotExists bool    `json:"isIfNotExists"`
}

StatementSummary is the SummarizeStatement response body.

type Table

type Table struct {
	TimeCreated   time.Time         `json:"timeCreated"`
	TimeUpdated   time.Time         `json:"timeUpdated"`
	Tags          Tags              `json:"tags"`
	TransitionAt  *time.Time        `json:"transitionAt,omitempty"`
	Rows          map[string]*Row   `json:"rows,omitempty"`
	Indexes       map[string]*Index `json:"indexes,omitempty"`
	Usage         map[int64]*Usage  `json:"usage,omitempty"`
	Identity      *Identity         `json:"identity,omitempty"`
	Replicas      []*Replica        `json:"replicas,omitempty"`
	CompartmentID string            `json:"compartmentId"`
	ID            string            `json:"id"`
	Name          string            `json:"name"`
	State         string            `json:"state"`
	DDL           string            `json:"ddl"`
	Etag          string            `json:"etag"`
	Columns       []Column          `json:"columns"`
	PrimaryKey    []string          `json:"primaryKey"`
	ShardKey      []string          `json:"shardKey"`
	Limits        Limits            `json:"limits"`
	TTLHours      int               `json:"ttlHours"`
	RowSeq        int64             `json:"rowSeq"`
	AutoReclaim   bool              `json:"autoReclaimable,omitempty"`
	SchemaFrozen  bool              `json:"schemaFrozen,omitempty"`
	// contains filtered or unexported fields
}

Table is a NoSQL table with its rows and indexes.

type TableList

type TableList struct {
	Items                  []TableWire `json:"items"`
	AutoReclaimableTables  int         `json:"autoReclaimableTables"`
	OnDemandCapacityTables int         `json:"onDemandCapacityTables"`
}

TableList is the ListTables result body.

type TableWire

type TableWire struct {
	TimeCreated       time.Time                 `json:"timeCreated"`
	TimeUpdated       time.Time                 `json:"timeUpdated"`
	Schema            *schemaWire               `json:"schema,omitempty"`
	FreeformTags      map[string]string         `json:"freeformTags,omitempty"`
	DefinedTags       map[string]map[string]any `json:"definedTags,omitempty"`
	LocalReplicaInit  *int                      `json:"localReplicaInitializationInPercent,omitempty"`
	Name              string                    `json:"name"`
	CompartmentID     string                    `json:"compartmentId"`
	ID                string                    `json:"id"`
	LifecycleState    string                    `json:"lifecycleState"`
	SchemaState       string                    `json:"schemaState"`
	DDLStatement      string                    `json:"ddlStatement,omitempty"`
	Replicas          []replicaWire             `json:"replicas,omitempty"`
	TableLimits       limitsWire                `json:"tableLimits"`
	IsAutoReclaimable bool                      `json:"isAutoReclaimable"`
	IsMultiRegion     bool                      `json:"isMultiRegion"`
}

TableWire is the full table representation.

type Tags

type Tags struct {
	FreeformTags map[string]string         `json:"freeformTags,omitempty"`
	DefinedTags  map[string]map[string]any `json:"definedTags,omitempty"`
}

Tags are the shared freeform and defined tag sets of a resource.

type UpdateRowResult

type UpdateRowResult struct {
	Version         *string        `json:"version"`
	ExistingVersion *string        `json:"existingVersion,omitempty"`
	GeneratedValue  *string        `json:"generatedValue,omitempty"`
	ExistingValue   jsontext.Value `json:"existingValue,omitempty"`
	Usage           usageWire      `json:"usage"`
}

UpdateRowResult is the UpdateRow response body.

type Usage

type Usage struct {
	Reads          int `json:"reads"`
	Writes         int `json:"writes"`
	ReadThrottles  int `json:"readThrottles,omitempty"`
	WriteThrottles int `json:"writeThrottles,omitempty"`
}

Usage is the consumption recorded for one minute.

type UsageWire

type UsageWire struct {
	TimeStarted          time.Time `json:"timeStarted"`
	SecondsInPeriod      int       `json:"secondsInPeriod"`
	ReadUnits            int       `json:"readUnits"`
	WriteUnits           int       `json:"writeUnits"`
	StorageInGBs         int       `json:"storageInGBs"`
	ReadThrottleCount    int       `json:"readThrottleCount"`
	WriteThrottleCount   int       `json:"writeThrottleCount"`
	StorageThrottleCount int       `json:"storageThrottleCount"`
}

UsageWire is one ListTableUsage item.

type WorkRequest

type WorkRequest struct {
	Accepted      time.Time `json:"accepted"`
	FinishAt      time.Time `json:"finishAt"`
	ID            string    `json:"id"`
	Operation     string    `json:"operation"`
	CompartmentID string    `json:"compartmentId"`
	EntityID      string    `json:"entityId"`
	Action        string    `json:"action"`
	EntityType    string    `json:"entityType,omitempty"`
	Seq           int64     `json:"seq"`
	Canceled      bool      `json:"canceled,omitempty"`
}

WorkRequest records an asynchronous admin operation.

type WorkRequestWire

type WorkRequestWire struct {
	TimeAccepted    time.Time        `json:"timeAccepted"`
	TimeStarted     *time.Time       `json:"timeStarted,omitempty"`
	TimeFinished    *time.Time       `json:"timeFinished,omitempty"`
	OperationType   string           `json:"operationType"`
	Status          string           `json:"status"`
	ID              string           `json:"id"`
	CompartmentID   string           `json:"compartmentId"`
	Resources       []wrResourceWire `json:"resources"`
	PercentComplete float32          `json:"percentComplete"`
}

WorkRequestWire is the wire form of a work request.

Jump to

Keyboard shortcuts

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