ormdb

package
v1.0.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModuleDB

type ModuleDB = ormtable.Schema

ModuleDB defines the ORM database type to be used by modules.

func NewModuleDB

func NewModuleDB(schema ModuleSchema, options ModuleDBOptions) (ModuleDB, error)

NewModuleDB constructs a ModuleDB instance from the provided schema and options.

type ModuleDBOptions

type ModuleDBOptions struct {

	// TypeResolver is an optional type resolver to be used when unmarshaling
	// protobuf messages. If it is nil, protoregistry.GlobalTypes will be used.
	TypeResolver ormtable.TypeResolver

	// FileResolver is an optional file resolver that can be used to retrieve
	// pinned file descriptors that may be different from those available at
	// runtime. The file descriptor versions returned by this resolver will be
	// used instead of the ones provided at runtime by the ModuleSchema.
	FileResolver protodesc.Resolver

	// JSONValidator is an optional validator that can be used for validating
	// messaging when using ValidateJSON. If it is nil, DefaultJSONValidator
	// will be used
	JSONValidator func(proto.Message) error

	// GetBackend is the function used to retrieve the table backend.
	// See ormtable.Options.GetBackend for more details.
	GetBackend func(context.Context) (ormtable.Backend, error)

	// GetReadBackend is the function used to retrieve a table read backend.
	// See ormtable.Options.GetReadBackend for more details.
	GetReadBackend func(context.Context) (ormtable.ReadBackend, error)
}

ModuleDBOptions are options for constructing a ModuleDB.

type ModuleSchema

type ModuleSchema struct {
	// FileDescriptors are the file descriptors that contain ORM tables to use in this schema.
	// Each file descriptor must have an unique non-zero uint32 ID associated with it.
	FileDescriptors map[uint32]protoreflect.FileDescriptor

	// Prefix is an optional prefix to prepend to all keys. It is recommended
	// to leave it empty.
	Prefix []byte
}

ModuleSchema describes the ORM schema for a module.

Jump to

Keyboard shortcuts

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