resdoc

package
v0.0.0-...-5004fd2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPartitionKey = errors.New("invalid partition key")
	ErrInvalidIdentifier   = errors.New("invalid identifier")
)
View Source
var (
	ErrAzCosmosDocNotFound = errors.New("az cosmos doc not found")
)

Functions

func HandleAzCosmosError

func HandleAzCosmosError(err error) error

func NewAzCosmosSingleContainerDocService

func NewAzCosmosSingleContainerDocService(client *azcosmos.ContainerClient) *azcosmosSingleContainerDocService

Types

type ContextKey

type ContextKey int
const (
	DocServiceContextKey ContextKey = iota
)

type CosmosQueryBuilder

type CosmosQueryBuilder struct {
	Columns           []string
	WhereClauses      []string
	OrderBy           string
	Parameters        []azcosmos.QueryParameter
	OffsetLimitClause string
}

func NewDefaultCosmoQueryBuilder

func NewDefaultCosmoQueryBuilder() *CosmosQueryBuilder

func (*CosmosQueryBuilder) BuildQuery

func (b *CosmosQueryBuilder) BuildQuery() (string, []azcosmos.QueryParameter)

func (*CosmosQueryBuilder) WithExtraColumns

func (b *CosmosQueryBuilder) WithExtraColumns(columns ...string) *CosmosQueryBuilder

func (*CosmosQueryBuilder) WithOffsetLimit

func (b *CosmosQueryBuilder) WithOffsetLimit(offset uint, limit uint) *CosmosQueryBuilder

func (*CosmosQueryBuilder) WithOrderBy

func (b *CosmosQueryBuilder) WithOrderBy(clause string) *CosmosQueryBuilder

func (*CosmosQueryBuilder) WithWhereClauses

func (b *CosmosQueryBuilder) WithWhereClauses(clauses ...string) *CosmosQueryBuilder

type DocIdentifier

type DocIdentifier struct {
	PartitionKey
	ID string
}

func NewDocIdentifier

func NewDocIdentifier(nsProvider models.NamespaceProvider,
	nsID string,
	rProvider models.ResourceProvider,
	id string) DocIdentifier

func ParseIdentifier

func ParseIdentifier(text string) (identifier DocIdentifier, err error)

func (*DocIdentifier) IsEmpty

func (p *DocIdentifier) IsEmpty() bool

func (DocIdentifier) MarshalText

func (p DocIdentifier) MarshalText() ([]byte, error)

func (DocIdentifier) String

func (p DocIdentifier) String() string

func (*DocIdentifier) UnmarshalText

func (p *DocIdentifier) UnmarshalText(text []byte) (err error)

type DocPager

type DocPager[D ResourceQueryDocument] struct {
	// contains filtered or unexported fields
}

func NewQueryDocPager

func NewQueryDocPager[D ResourceQueryDocument](c context.Context,
	queryBuilder *CosmosQueryBuilder,
	partitionKey PartitionKey) *DocPager[D]

func (*DocPager[D]) More

func (p *DocPager[D]) More() bool

func (*DocPager[D]) NextPage

func (p *DocPager[D]) NextPage() (items []D, err error)

type ETag

type ETag = azcore.ETag

type HexBytes

type HexBytes []byte

func (HexBytes) MarshalText

func (s HexBytes) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler.

func (HexBytes) String

func (s HexBytes) String() string

func (*HexBytes) UnmarshalText

func (s *HexBytes) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type LinkResourceDoc

type LinkResourceDoc struct {
	ResourceDoc
	LinkTo       DocIdentifier       `json:"linkTo"`
	LinkProvider models.LinkProvider `json:"linkProvider"`
}

func (*LinkResourceDoc) ToModel

func (doc *LinkResourceDoc) ToModel() (m models.LinkRef)

type NumericDate

type NumericDate = jwt.NumericDate

type PartitionKey

type PartitionKey struct {
	NamespaceProvider models.NamespaceProvider
	NamespaceID       string
	ResourceProvider  models.ResourceProvider
}

func ParsePartitionKey

func ParsePartitionKey(text string) (PartitionKey, error)

func (*PartitionKey) IsEmpty

func (p *PartitionKey) IsEmpty() bool

func (PartitionKey) MarshalText

func (p PartitionKey) MarshalText() ([]byte, error)

func (PartitionKey) String

func (p PartitionKey) String() string

func (*PartitionKey) UnmarshalText

func (p *PartitionKey) UnmarshalText(text []byte) (err error)

type ResourceDoc

type ResourceDoc struct {
	PartitionKey PartitionKey     `json:"namespaceId"`
	ID           string           `json:"id"`
	Timestamp    *jwt.NumericDate `json:"_ts,omitempty"`
	ETag         *ETag            `json:"_etag,omitempty"`
	Deleted      *time.Time       `json:"deleted,omitempty"`
	UpdatedBy    string           `json:"updatedBy,omitempty"`
}

Docs are IDed by the following (?<partitionID>:)<namespaceProvider>:<namespaceID>:<resourceProvider>/<resourceID>

func (*ResourceDoc) GetETag

func (doc *ResourceDoc) GetETag() *azcore.ETag

GetETag implements ResourceDocument.

func (*ResourceDoc) Identifier

func (doc *ResourceDoc) Identifier() DocIdentifier

func (*ResourceDoc) ToRef

func (doc *ResourceDoc) ToRef() (ref models.Ref)

type ResourceDocument

type ResourceDocument interface {
	Identifier() DocIdentifier

	GetETag() *azcore.ETag
	// contains filtered or unexported methods
}

type ResourceQueryDoc

type ResourceQueryDoc struct {
	ID        string          `json:"id"`
	Timestamp jwt.NumericDate `json:"_ts"`
	Deleted   *time.Time      `json:"deleted"`
}

func (*ResourceQueryDoc) ToRef

func (d *ResourceQueryDoc) ToRef() (m models.Ref)

// PopulateModelRef implements ModelRefPopulater.

type ResourceQueryDocument

type ResourceQueryDocument interface {
}

Jump to

Keyboard shortcuts

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