gcsutil

package
v1.44.9 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MPL-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package gcsutil contains some generic utilities to support gcsemu. TODO(dragonsinth): consider open sourcing these separately, or finding open source replacements.

Index

Constants

This section is empty.

Variables

View Source
var File_gcspagetoken_proto protoreflect.FileDescriptor

Functions

func DecodePageToken

func DecodePageToken(pageToken string) (string, error)

DecodePageToken decodes a GCS pageToken to the name of the last file returned.

func EncodePageToken

func EncodePageToken(greaterThan string) string

EncodePageToken returns a synthetic page token to find files greater than the given string. If this is part of a prefix query, the token should fall within the prefixed range. BRITTLE: relies on a reverse-engineered internal GCS token format, which may be subject to change.

Types

type GcsPageToken

type GcsPageToken struct {

	// The full name of the last result file, when returned from the server.
	// When sent as a cursor, interpreted as "return files greater than this value".
	LastFile string `protobuf:"bytes,1,opt,name=LastFile,proto3" json:"LastFile,omitempty"`
	// contains filtered or unexported fields
}

func (*GcsPageToken) Descriptor deprecated

func (*GcsPageToken) Descriptor() ([]byte, []int)

Deprecated: Use GcsPageToken.ProtoReflect.Descriptor instead.

func (*GcsPageToken) GetLastFile

func (x *GcsPageToken) GetLastFile() string

func (*GcsPageToken) ProtoMessage

func (*GcsPageToken) ProtoMessage()

func (*GcsPageToken) ProtoReflect

func (x *GcsPageToken) ProtoReflect() protoreflect.Message

func (*GcsPageToken) Reset

func (x *GcsPageToken) Reset()

func (*GcsPageToken) String

func (x *GcsPageToken) String() string

type TransientLockMap

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

TransientLockMap is a map of mutexes that is safe for concurrent access. It does not bother to save mutexes after they have been unlocked, and thus this data structure is best for situations where the space of keys is very large. If the space of keys is small then it may be inefficient to constantly recreate mutexes whenever they are needed.

func NewTransientLockMap

func NewTransientLockMap() *TransientLockMap

NewTransientLockMap returns a new TransientLockMap.

func (*TransientLockMap) Lock

func (l *TransientLockMap) Lock(ctx context.Context, key string) bool

Lock acquires the lock for the specified key and returns true, unless the context finishes before the lock could be acquired, in which case false is returned.

func (*TransientLockMap) Run

func (l *TransientLockMap) Run(ctx context.Context, key string, f func(ctx context.Context) error) error

Run runs the given callback while holding the lock, unless the context finishes before the lock could be acquired, in which case the context error is returned.

func (*TransientLockMap) Unlock

func (l *TransientLockMap) Unlock(key string)

Unlock unlocks the lock for the specified key. Panics if the lock is not currently held.

Jump to

Keyboard shortcuts

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