sql

package
v0.0.0-...-6de12c4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package sql implements server model interfaces. Supports at least SQLite and PostgreSQL.

Index

Constants

View Source
const InventorySchema = `` /* 336-byte string literal not displayed */
View Source
const NonceSchema = `` /* 219-byte string literal not displayed */
View Source
const SourceSchema = `` /* 138-byte string literal not displayed */

Variables

View Source
var Adapter = database.Register(&database.Adapter{
	Name: "sql",

	NewConfig: func() database.Config {
		return &adaptedConfig{
			Config: DefaultConfig.Clone(),
		}
	},

	Open: func(config database.Config) (database.Endpoint, error) {
		x, err := Open(config.(*adaptedConfig).Config)
		if err != nil {
			return nil, err
		}
		return x, err
	},

	InitInventory: func(ctx Context, endpoint database.Endpoint) (model.Inventory, error) {
		x := endpoint.(*Endpoint)
		if err := x.InitInventory(ctx); err != nil {
			return nil, err
		}
		return x, nil
	},

	InitSourceCache: func(ctx Context, endpoint database.Endpoint) (model.SourceCache, error) {
		x := endpoint.(*Endpoint)
		if err := x.InitSourceCache(ctx); err != nil {
			return nil, err
		}
		return x, nil
	},

	InitNonceChecker: func(ctx Context, endpoint database.Endpoint) (model.NonceChecker, error) {
		x := endpoint.(*Endpoint)
		if err := x.InitNonceChecker(ctx); err != nil {
			return nil, err
		}
		return x, nil
	},
})

Functions

This section is empty.

Types

type Config

type Config struct {
	Driver string
	DSN    string
}
var DefaultConfig Config

func (*Config) Clone

func (c *Config) Clone() Config

func (*Config) Enabled

func (c *Config) Enabled() bool

func (*Config) Equal

func (c *Config) Equal(other Config) bool

type Endpoint

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

func Open

func Open(config Config) (*Endpoint, error)

func (*Endpoint) CheckNonce

func (x *Endpoint) CheckNonce(ctx Context, scope []byte, nonce string, expire time.Time) error

func (*Endpoint) Close

func (x *Endpoint) Close() error

func (*Endpoint) GetInstance

func (x *Endpoint) GetInstance(ctx Context, pri principal.ID, instance string, buf proto.Message) (bool, error)

func (*Endpoint) GetModule

func (x *Endpoint) GetModule(ctx Context, pri principal.ID, module string, buf proto.Message) (bool, error)

func (*Endpoint) GetSourceSHA256

func (x *Endpoint) GetSourceSHA256(ctx Context, source string) (string, error)

func (*Endpoint) InitInventory

func (x *Endpoint) InitInventory(ctx Context) error

func (*Endpoint) InitNonceChecker

func (x *Endpoint) InitNonceChecker(ctx Context) error

func (*Endpoint) InitSourceCache

func (x *Endpoint) InitSourceCache(ctx Context) error

func (*Endpoint) PutInstance

func (x *Endpoint) PutInstance(ctx Context, pri principal.ID, instance string, buf proto.Message) error

func (*Endpoint) PutModule

func (x *Endpoint) PutModule(ctx Context, pri principal.ID, module string, buf proto.Message) error

func (*Endpoint) PutSourceSHA256

func (x *Endpoint) PutSourceSHA256(ctx Context, source, module string) error

func (*Endpoint) RemoveInstance

func (x *Endpoint) RemoveInstance(ctx Context, pri principal.ID, instance string) error

func (*Endpoint) RemoveModule

func (x *Endpoint) RemoveModule(ctx Context, pri principal.ID, module string) error

func (*Endpoint) UpdateInstance

func (x *Endpoint) UpdateInstance(ctx Context, pri principal.ID, instance string, buf proto.Message) error

func (*Endpoint) UpdateModule

func (x *Endpoint) UpdateModule(ctx Context, pri principal.ID, module string, buf proto.Message) error

Jump to

Keyboard shortcuts

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