Documentation
¶
Overview ¶
Package zedtoken contains helper functions to handle zedtokens.
Index ¶
- Variables
- func Decode(encoded *v1.ZedToken) (*zedtoken.DecodedZedToken, error)
- func Encode(decoded *zedtoken.DecodedZedToken) (*v1.ZedToken, error)
- func MustNewFromRevisionForTesting(revision datastore.Revision, schemaHash datalayer.SchemaHash) *v1.ZedToken
- func NewFromRevision(ctx context.Context, revision datastore.Revision, ...) (*v1.ZedToken, error)
- func NewFromRevisionNoDatastoreID(revision datastore.Revision, schemaHash datalayer.SchemaHash) (*v1.ZedToken, error)
- type DecodedRevision
- type RevisionHolder
- type TokenStatus
Constants ¶
This section is empty.
Variables ¶
var ErrNilZedToken = errors.New("zedtoken pointer was nil")
ErrNilZedToken is returned as the base error when nil is provided as the zedtoken argument to Decode
Functions ¶
func Decode ¶
func Decode(encoded *v1.ZedToken) (*zedtoken.DecodedZedToken, error)
Decode converts an encoded zedtoken to its decoded version.
func Encode ¶
func Encode(decoded *zedtoken.DecodedZedToken) (*v1.ZedToken, error)
Encode converts a decoded zedtoken to its opaque version.
func MustNewFromRevisionForTesting ¶ added in v1.46.0
func MustNewFromRevisionForTesting(revision datastore.Revision, schemaHash datalayer.SchemaHash) *v1.ZedToken
MustNewFromRevisionForTesting generates an encoded zedtoken from an integral revision.
func NewFromRevision ¶
func NewFromRevision(ctx context.Context, revision datastore.Revision, schemaHash datalayer.SchemaHash, ds RevisionHolder) (*v1.ZedToken, error)
NewFromRevision generates an encoded zedtoken from a revision and schema hash.
func NewFromRevisionNoDatastoreID ¶ added in v1.46.1
func NewFromRevisionNoDatastoreID(revision datastore.Revision, schemaHash datalayer.SchemaHash) (*v1.ZedToken, error)
NewFromRevisionNoDatastoreID generates an encoded zedtoken without a datastore ID. This is only for use in legacy scenarios. Most callers should use NewFromRevision.
Types ¶
type DecodedRevision ¶ added in v1.54.0
type DecodedRevision struct {
Revision datastore.Revision
SchemaHash datalayer.SchemaHash
Status TokenStatus
}
DecodedRevision is the result of decoding a zedtoken. SchemaHash is NoSchemaHashInLegacyZedToken for tokens that pre-date the schema_hash field, or whose Status is not StatusValid.
func DecodeRevision ¶
func DecodeRevision(encoded *v1.ZedToken, ds RevisionHolder) (DecodedRevision, error)
DecodeRevision converts and extracts the revision and schema hash from a zedtoken or legacy zookie.
type RevisionHolder ¶ added in v1.46.1
type RevisionHolder interface {
// UniqueID returns the unique ID of the holder (typically: a datastore).
UniqueID(context.Context) (string, error)
// RevisionFromString converts a string representation of a revision to a Revision.
RevisionFromString(string) (datastore.Revision, error)
}
RevisionHolder is an interface for types that can provide a unique ID and revision information.
type TokenStatus ¶ added in v1.46.0
type TokenStatus int
TokenStatus is the status of a zedtoken.
const ( // StatusUnknown indicates that the status of the zedtoken is unknown. StatusUnknown TokenStatus = iota // StatusLegacyEmptyDatastoreID indicates that the zedtoken is a legacy token // with an empty datastore ID. StatusLegacyEmptyDatastoreID // StatusValid indicates that the zedtoken is valid. StatusValid // StatusMismatchedDatastoreID indicates that the zedtoken is valid, but the // datastore ID does not match the current datastore, indicating that the // token was generated by a different datastore instance. StatusMismatchedDatastoreID )