etag

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ETagEncoding = base32.NewEncoding(encodeEtag).WithPadding(base32.NoPadding)

ETagEncoding is base32.Encoding for human-readable text presentation of internal ETag values

Functions

func AddScope

func AddScope(scope []string, names ...string) []string

AddScope appends UNIQUE(+lower) names to scope and returns, optionaly new, scope slice

func AppendTag

func AppendTag(dst []byte, typ EtagType, oid int64, ver int32) []byte

func DecodeTag

func DecodeTag(s string) (typ EtagType, tag Tid, err error)

func EncodeEtag

func EncodeEtag(typ EtagType, oid int64, ver int32) (string, error)

func EncodeTag

func EncodeTag(typ EtagType, tag Tid) (string, error)

func FieldsCopy

func FieldsCopy(fields []string) []string

FieldsCopy returns copy of unique set of given fields, all are in lower case

func FieldsFunc

func FieldsFunc(src []string, fn func(string) []string) []string

FieldsFunc normalize a selection list src of the attributes to be returned.

  1. An empty list with no attributes requests the return of all user attributes.
  2. A list containing "*" (with zero or more attribute descriptions) requests the return of all user attributes in addition to other listed (operational) attributes.

e.g.: ['id,name','display'] returns ['id','name','display']

func GetId

func GetId(typ EtagType, oid int64) (id string, err error)

GetId formats the given serial OID identifier into a string presentation.

func GetOid

func GetOid(typ EtagType, id string) (oid int64, err error)

GetOid parses the given id string into a serial unique OID identifier.

func HasScope

func HasScope(scope []string, name string) bool

func InlineFields

func InlineFields(selector string) []string

InlineFields explode inline 'attr,attr2 attr3' selector as ['attr','attr2','attr3']

func MergeFields

func MergeFields(dst, src []string) []string

MergeFields appends unique set from src to dst.

func MustId

func MustId(typ EtagType, id string, err error) string

MustId ensures that the ID is valid or panics if it is not.

func Name

func Name(s string) string

Name canonize s to alphanumeric lower code name

func SelectFields

func SelectFields(userattrs, operational []string) func(string) []string

SelectFields maps['*':userattrs, '+':userattrs+allattrs]

func UniqueId

func UniqueId(this, that INode) error

Types

type Constraint

type Constraint[TNode INode] func(this TNode) error

Constraint checks given this INode for data integrity violations.

func RequireId

func RequireId[TNode INode](nodeOf string, typ EtagType) Constraint[TNode]

RequireId constraint RequireId ensures that the node's ID is not empty, returns an error if missing.

type ETag

type ETag struct {
	// Object id of the object
	Tid
	// Tuple id of the object
	EtagType
}

ETag Object reference

func (*ETag) String

func (e *ETag) String() (string, error)

func (*ETag) Valid

func (e *ETag) Valid() error

type EtagType

type EtagType uint32

EtagType represents the [E]Tag object type reference.

const (
	NoType                EtagType = iota // NoType represents an unknown or invalid type
	EtagCase                              // Case type
	EtagCaseComment                       // Case Comment type
	EtagCaseLink                          // Case Link type
	EtagRelatedCase                       // Case Related case type
	EtagCaseCommunication                 // Case Related case type
)

Case-related ETag types are declared here. **For generating string : ** go install golang.org/x/tools/cmd/stringer@latest echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.zshrc source ~/.zshrc go generate ./... **Commands**

func ConsumeTag

func ConsumeTag(src []byte) (typ EtagType, oid int64, ver int32, n int)

func DecodeEtag

func DecodeEtag(s string) (typ EtagType, oid int64, ver int32, err error)

func (EtagType) String

func (i EtagType) String() string

type IList

type IList[TNode INode] interface {
	GetData() []TNode
}

type INode

type INode interface {
	// GetId MUST return an unique identifier of this data node.
	GetId() string

	// FIXME: Accept: proto.Message(s)
	ProtoMessage
}

INode interface represents single data node within contacts package schema.

type IRemovable

type IRemovable interface {
	// Positive timestamp indicates that this source
	// was temporary removed from main view.
	GetDeletedAt() int64
}

IRemovable interface

type IVersional

type IVersional interface {
	// MUST implements INode
	INode
	// GetVertion returns latest revision(version) number of this data node.
	GetVer() int32
}

IVersional interface

type IVisitor

type IVisitor[TNode INode] interface {
	// Check given node for data integrity violations.
	Constraint(input TNode) error
	// Check given nodes for violations of data uniqueness.
	UniqueConstraint(input, exist TNode) error
}

type ProtoMessage

type ProtoMessage = protoreflect.ProtoMessage

ProtoMessage reflects: - google.golang.org/protobuf/proto.Message - github.com/golang/protobuf/proto.MessageV2() protoV2.Message

type Tag

type Tag struct {
	// Encoded tuple identifier
	Tid
	// Encoded string identifier
	Id string
}

func (*Tag) IsEtag

func (e *Tag) IsEtag() bool

func (*Tag) IsZero

func (e *Tag) IsZero() bool

type Tid

type Tid struct {
	// OPTIONAL. Tuple revision number.
	// Zero-based integer sequence number.
	// REQUIRED. As a part of ETag identifier.
	Ver *int32
	// REQUIRED. Tuple unique identifier.
	// Positive non-zero integer number.
	Oid int64
}

The [T]uple [ID]entifier is a pointer to a specific version of the unique tuple.

func EtagOrId

func EtagOrId(of EtagType, s string) (tag Tid, err error)

EtagOrId parses the input as either a valid ETag or a unique object identifier.

func ExpectEtag

func ExpectEtag(of EtagType, s string) (tag Tid, err error)

ExpectETag parses a given string as an ETag string of the expected reference type.

func GetTag

func GetTag(node IVersional, typ EtagType) (tag Tid, err error)

GetTag from given node dynamically uses the type

func (*Tid) GetId

func (e *Tid) GetId(typ EtagType) string

GetId returns string format of the Oid identifier dynamically using the passed type.

func (*Tid) GetOid

func (e *Tid) GetOid() int64

GetOid returns the tuple's unique integer identifier or zero.

func (*Tid) GetVer

func (e *Tid) GetVer() int32

GetVer returns the associated tuple version or zero.

func (*Tid) HasOid

func (e *Tid) HasOid() bool

HasOid reports whether e is valid.

func (*Tid) HasVer

func (e *Tid) HasVer() bool

HasVer reports whether the tuple version is associated. True means e was build from -or- can be used for ETag identifier.

func (*Tid) IsNone

func (e *Tid) IsNone() bool

IsZero reports whether e points to any tuple.

func (*Tid) IsVer

func (e *Tid) IsVer(num int32) bool

VerOf reports whether e.Ver associated and v equals to e.Ver.

func (*Tid) Valid

func (e *Tid) Valid() error

type Tids

type Tids []Tid

func InputIdOrEtag

func InputIdOrEtag(typeOf EtagType, input ...string) (data Tids, err error)

InputIdOrEtag parses <input> set of UNIQUE [id!].

func (Tids) IsNone

func (e Tids) IsNone() bool

func (Tids) Oids

func (e Tids) Oids() []int64

type UniqueConstraint

type UniqueConstraint[TNode INode] func(this, that TNode) error

UniqueConstraint checks given INode(s) for violations of data uniqueness.

Jump to

Keyboard shortcuts

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