common

package
v0.3.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleSQLError

func HandleSQLError(err error, args ...interface{}) error

Types

type Config

type Config struct {
	Logger                 logger.Logger
	MaxTuplesPerWriteField int
	MaxTypesPerModelField  int

	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxIdleTime time.Duration
	ConnMaxLifetime time.Duration
}

func NewConfig

func NewConfig(opts ...DatastoreOption) *Config

type ContToken

type ContToken struct {
	Ulid       string `json:"ulid"`
	ObjectType string `json:"ObjectType"`
}

func NewContToken

func NewContToken(ulid, objectType string) *ContToken

func UnmarshallContToken

func UnmarshallContToken(from string) (*ContToken, error)

type DatastoreOption

type DatastoreOption func(*Config)

func WithConnMaxIdleTime

func WithConnMaxIdleTime(d time.Duration) DatastoreOption

func WithConnMaxLifetime

func WithConnMaxLifetime(d time.Duration) DatastoreOption

func WithLogger

func WithLogger(l logger.Logger) DatastoreOption

func WithMaxIdleConns

func WithMaxIdleConns(c int) DatastoreOption

func WithMaxOpenConns

func WithMaxOpenConns(c int) DatastoreOption

func WithMaxTuplesPerWrite

func WithMaxTuplesPerWrite(maxTuples int) DatastoreOption

func WithMaxTypesPerAuthorizationModel

func WithMaxTypesPerAuthorizationModel(maxTypes int) DatastoreOption

type SQLObjectIterator

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

func NewSQLObjectIterator

func NewSQLObjectIterator(rows *sql.Rows) *SQLObjectIterator

NewSQLObjectIterator returns a tuple iterator for Postgres

func (*SQLObjectIterator) Next

func (o *SQLObjectIterator) Next() (*openfgapb.Object, error)

func (*SQLObjectIterator) Stop

func (o *SQLObjectIterator) Stop()

type SQLTupleIterator

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

func NewSQLTupleIterator

func NewSQLTupleIterator(rows *sql.Rows) *SQLTupleIterator

NewSQLTupleIterator returns a SQL tuple iterator

func (*SQLTupleIterator) Next

func (t *SQLTupleIterator) Next() (*openfgapb.Tuple, error)

func (*SQLTupleIterator) Stop

func (t *SQLTupleIterator) Stop()

func (*SQLTupleIterator) ToArray

ToArray converts the tupleIterator to an []*openfgapb.Tuple and a possibly empty continuation token. If the continuation token exists it is the ulid of the last element of the returned array.

type TupleRecord

type TupleRecord struct {
	Store      string
	ObjectType string
	ObjectID   string
	Relation   string
	User       string
	Ulid       string
	InsertedAt time.Time
}

func (*TupleRecord) AsTuple

func (t *TupleRecord) AsTuple() *openfgapb.Tuple

Jump to

Keyboard shortcuts

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