invocations

package
v0.0.0-...-8ff35f7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const Shards = 100

Shards is the sharding level for the Invocations table. Column Invocations.ShardId is a value in range [0, Shards).

Variables

This section is empty.

Functions

func CurrentMaxShard

func CurrentMaxShard(ctx context.Context) (int, error)

CurrentMaxShard reads the highest shard id in the Invocations table. This may differ from the constant above when it has changed recently.

func InclusionKey

func InclusionKey(including, included ID) spanner.Key

InclusionKey returns a spanner key for an Inclusion row.

func QueryRealms

func QueryRealms(ctx context.Context, ids IDSet) (realms map[ID]string, err error)

QueryRealms returns the invocations' realms where available from the Invocations table. Makes a single RPC.

func Read

func Read(ctx context.Context, id ID) (*pb.Invocation, error)

Read reads one invocation from Spanner. If the invocation does not exist, the returned error is annotated with NotFound GRPC code.

func ReadBatch

func ReadBatch(ctx context.Context, ids IDSet) (map[ID]*pb.Invocation, error)

ReadBatch reads multiple invocations from Spanner. If any of them are not found, returns an error.

func ReadColumns

func ReadColumns(ctx context.Context, id ID, ptrMap map[string]any) error

ReadColumns reads the specified columns from an invocation Spanner row. If the invocation does not exist, the returned error is annotated with NotFound GRPC code. For ptrMap see ReadRow comment in span/util.go.

func ReadRealm

func ReadRealm(ctx context.Context, id ID) (string, error)

ReadRealm returns the invocation's realm.

func ReadRealms

func ReadRealms(ctx context.Context, ids IDSet) (realms map[ID]string, err error)

ReadRealms returns the invocations' realms. Returns a NotFound error if unable to get the realm for any of the requested invocations. Makes a single RPC.

func ReadState

func ReadState(ctx context.Context, id ID) (pb.Invocation_State, error)

ReadState returns the invocation's state.

func ReadStateBatch

func ReadStateBatch(ctx context.Context, ids IDSet) (map[ID]pb.Invocation_State, error)

ReadStateBatch reads the states of multiple invocations.

func ReadSubmitted

func ReadSubmitted(ctx context.Context, id ID) (bool, error)

ReadSubmitted returns the invocation's submitted status.

func TokenToMap

func TokenToMap(token string, dest map[string]any, keys ...string) error

TokenToMap parses a page token to a map. The first component of the token is expected to be an invocation ID. Convenient to initialize Spanner statement parameters. Expects the token to be either empty or have len(keys) components. If the token is empty, sets map values to "".

Types

type ExportInfo

type ExportInfo struct {
	// Whether the invocation is in FINALIZED or FINALIZING state.
	IsInvocationFinal bool
	// The realm of the invocation.
	Realm string
	// IsSourcesSpecFinalEffective whether the source information is immutable.
	// This is true if either IsSourceSpecFinal is set on the invocation, or
	// the invocation is in FINALIZING or FINALIZED state.
	IsSourceSpecFinalEffective bool
	// IsInheritingSources contains whether the invocation is inheriting sources
	// from its parent (including) invocation.
	IsInheritingSources bool
	// Sources are the concrete sources specific on the invocation (if any).
	Sources *pb.Sources
}

ExportInfo captures information pertinent to exporting an invocation and propogating export roots.

func ReadExportInfo

func ReadExportInfo(ctx context.Context, invID ID) (ExportInfo, error)

ReadExportInfo reads information pertinent to exporting an invocation.

type FinalizedNotificationInfo

type FinalizedNotificationInfo struct {
	// The realm of the invocation.
	Realm string
	// Whether this invocation is a root of the invocation graph for export purposes.
	IsExportRoot bool
	// When the invocation was created.
	CreateTime *timestamppb.Timestamp
}

FinalizedNotificationInfo captures information for sending an invocation finalized notification.

func ReadFinalizedNotificationInfo

func ReadFinalizedNotificationInfo(ctx context.Context, invID ID) (FinalizedNotificationInfo, error)

ReadFinalizedNotificationInfo reads information for sending an invocation finalized notification.

type ID

type ID string

ID can convert an invocation id to various formats.

func IDFromRowID

func IDFromRowID(rowID string) ID

IDFromRowID converts a Spanner-level row ID to an ID.

func MustParseName

func MustParseName(name string) ID

MustParseName converts an invocation name to an ID. Panics if the name is invalid. Useful for situations when name was already validated.

func (*ID) FromSpanner

func (id *ID) FromSpanner(b *spanutil.Buffer) error

FromSpanner implements span.Ptr.

func (ID) Key

func (id ID) Key(suffix ...any) spanner.Key

Key returns a invocation spanner key.

func (ID) Name

func (id ID) Name() string

Name returns an invocation name.

func (ID) RowID

func (id ID) RowID() string

RowID returns an invocation ID used in spanner rows. If id is empty, returns "".

func (*ID) SpannerPtr

func (id *ID) SpannerPtr(b *spanutil.Buffer) any

SpannerPtr implements span.Ptr.

func (ID) ToSpanner

func (id ID) ToSpanner() any

ToSpanner implements span.Value.

type IDSet

type IDSet map[ID]struct{}

IDSet is an unordered set of invocation ids.

func MustParseNames

func MustParseNames(names []string) IDSet

MustParseNames converts invocation names to IDSet. Panics if a name is invalid. Useful for situations when names were already validated.

func NewIDSet

func NewIDSet(ids ...ID) IDSet

NewIDSet creates an IDSet from members.

func ParseNames

func ParseNames(names []string) (IDSet, error)

ParseNames converts invocation names to IDSet.

func ReadIncluded

func ReadIncluded(ctx context.Context, id ID) (IDSet, error)

ReadIncluded reads ids of (directly) included invocations.

func (IDSet) Add

func (s IDSet) Add(id ID)

Add adds id to the set.

func (IDSet) Batch

func (s IDSet) Batch(batchSize int) []IDSet

Batch returns IDs in the set in batches of size batchSize.

func (*IDSet) FromSpanner

func (s *IDSet) FromSpanner(b *spanutil.Buffer) error

FromSpanner implements span.Ptr.

func (IDSet) Has

func (s IDSet) Has(id ID) bool

Has returns true if id is in the set.

func (IDSet) Intersect

func (s IDSet) Intersect(other IDSet) IDSet

Intersect returns only the ids present in this set and other.

func (IDSet) Keys

func (s IDSet) Keys(suffix ...any) spanner.KeySet

Keys returns a spanner.KeySet.

func (IDSet) Names

func (s IDSet) Names() []string

Names returns a sorted slice of invocation names.

func (IDSet) Remove

func (s IDSet) Remove(id ID)

Remove removes id from the set if it was present.

func (IDSet) RemoveAll

func (s IDSet) RemoveAll(other IDSet)

RemoveAll removes any ids present in other.

func (IDSet) SortByRowID

func (s IDSet) SortByRowID() []ID

SortByRowID returns IDs in the set sorted by row id.

func (*IDSet) SpannerPtr

func (s *IDSet) SpannerPtr(b *spanutil.Buffer) any

SpannerPtr implements span.Ptr.

func (IDSet) String

func (s IDSet) String() string

String implements fmt.Stringer.

func (IDSet) ToSpanner

func (s IDSet) ToSpanner() any

ToSpanner implements span.Value.

func (IDSet) Union

func (s IDSet) Union(other IDSet)

Union adds other ids.

Directories

Path Synopsis
Package graph contains methods to explore reachable invocations.
Package graph contains methods to explore reachable invocations.

Jump to

Keyboard shortcuts

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