Documentation ¶
Overview ¶
Package data contains util fns for reading and writing data handled by the cron job.
Index ¶
- Variables
- func BlobExists(ctx context.Context, bucketURL, key string) (bool, error)
- func GetBlobContent(ctx context.Context, bucketURL, key string) ([]byte, error)
- func GetBlobFilename(filename string, datetime time.Time) string
- func GetBlobKeys(ctx context.Context, bucketURL string) ([]string, error)
- func GetBlobKeysWithPrefix(ctx context.Context, bucketURL, filePrefix string) ([]string, error)
- func GetShardMetadataFilename(datetime time.Time) string
- func GetShardNumFilename(datetime time.Time) string
- func GetTransferStatusFilename(datetime time.Time) string
- func ParseBlobFilename(key string) (time.Time, string, error)
- func SortAndAppendFrom(in io.Reader, out io.Writer, newRepos []RepoFormat) error
- func SortAndAppendTo(out io.Writer, oldRepos, newRepos []RepoFormat) error
- func WriteTo(out io.Writer, repos []RepoFormat) error
- func WriteToBlobStore(ctx context.Context, bucketURL, filename string, data []byte) error
- type BucketSummary
- type CSVStrings
- type Iterator
- type Repo
- type RepoFormat
- type ScorecardBatchRequest
- func (*ScorecardBatchRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ScorecardBatchRequest) GetJobTime() *timestamppb.Timestamp
- func (x *ScorecardBatchRequest) GetRepos() []*Repo
- func (x *ScorecardBatchRequest) GetShardNum() int32
- func (*ScorecardBatchRequest) ProtoMessage()
- func (x *ScorecardBatchRequest) ProtoReflect() protoreflect.Message
- func (x *ScorecardBatchRequest) Reset()
- func (x *ScorecardBatchRequest) String() string
- type ShardMetadata
- func (*ShardMetadata) Descriptor() ([]byte, []int)deprecated
- func (x *ShardMetadata) GetCommitSha() string
- func (x *ShardMetadata) GetNumShard() int32
- func (x *ShardMetadata) GetShardLoc() string
- func (*ShardMetadata) ProtoMessage()
- func (x *ShardMetadata) ProtoReflect() protoreflect.Message
- func (x *ShardMetadata) Reset()
- func (x *ShardMetadata) String() string
- type ShardSummary
Constants ¶
This section is empty.
Variables ¶
var File_cron_data_metadata_proto protoreflect.FileDescriptor
var File_cron_data_request_proto protoreflect.FileDescriptor
Functions ¶
func BlobExists ¶
BlobExists checks whether a given `bucketURL/key` blob exists.
func GetBlobContent ¶
GetBlobContent returns the file content given a bucketURL and object key.
func GetBlobFilename ¶
GetBlobFilename returns a blob key for a shard. Takes Time object and filename as input.
func GetBlobKeys ¶
GetBlobKeys returns all object keys for a given bucketURL.
func GetBlobKeysWithPrefix ¶ added in v4.9.0
GetBlobKeysWithPrefix returns all object keys for a given bucketURL which start with prefix. The prefix can be used to specify directories.
func GetShardMetadataFilename ¶
GetShardMetadataFilename returns shard_metadata filename for a shard.
func GetShardNumFilename ¶
GetShardNumFilename returns shard_num filename for a shard.
func GetTransferStatusFilename ¶
GetTransferStatusFilename returns transfer_status filename for a shard.
func ParseBlobFilename ¶
ParseBlobFilename parses a blob key into a Time object.
func SortAndAppendFrom ¶
SortAndAppendFrom reads from `in`, appends to newRepos and writes the sorted output to `out`.
func SortAndAppendTo ¶
func SortAndAppendTo(out io.Writer, oldRepos, newRepos []RepoFormat) error
SortAndAppendTo appends `oldRepos` and `newRepos` before sorting and writing out the result to `out`.
Types ¶
type BucketSummary ¶ added in v4.9.0
type BucketSummary struct {
// contains filtered or unexported fields
}
BucketSummary contains details about all the shards in a bucket grouped by their creation time.
func GetBucketSummary ¶ added in v4.9.0
func GetBucketSummary(ctx context.Context, bucketURL string) (*BucketSummary, error)
GetBucketSummary iterates through all files in a bucket and returns a BucketSummary with details on each set of shards grouped by creation time.
func (*BucketSummary) Shards ¶ added in v4.9.0
func (summary *BucketSummary) Shards() []*ShardSummary
Shards returns a slice of ShardSummary instances for each shard creation time.
type CSVStrings ¶
type CSVStrings []string
CSVStrings is []string with support for CSV formatting.
func (CSVStrings) MarshalCSV ¶
func (s CSVStrings) MarshalCSV() ([]byte, error)
MarshalCSV implements []string -> []byte serialization.
func (CSVStrings) ToString ¶
func (s CSVStrings) ToString() []string
ToString converts CSVStrings -> []string.
func (*CSVStrings) UnmarshalCSV ¶
func (s *CSVStrings) UnmarshalCSV(input []byte) error
UnmarshalCSV implements []byte -> []string de-serializtion.
type Iterator ¶
type Iterator interface { HasNext() bool Next() (RepoFormat, error) }
Iterator interface is used to iterate through list of input repos for the cron job.
func MakeIteratorFrom ¶
MakeIteratorFrom returns an implementation of Iterator interface. Currently returns an instance of csvIterator.
func MakeNestedIterator ¶ added in v4.9.0
type Repo ¶
type Repo struct { Url *string `protobuf:"bytes,1,opt,name=url,proto3,oneof" json:"url,omitempty"` Commit *string `protobuf:"bytes,3,opt,name=commit,proto3,oneof" json:"commit,omitempty"` Metadata []string `protobuf:"bytes,2,rep,name=metadata,proto3" json:"metadata,omitempty"` // contains filtered or unexported fields }
func (*Repo) Descriptor
deprecated
func (*Repo) GetMetadata ¶
func (*Repo) ProtoMessage ¶
func (*Repo) ProtoMessage()
func (*Repo) ProtoReflect ¶
func (x *Repo) ProtoReflect() protoreflect.Message
type RepoFormat ¶
type RepoFormat struct { Repo string `csv:"repo"` Metadata CSVStrings `csv:"metadata"` }
RepoFormat is used to read input repos.
type ScorecardBatchRequest ¶
type ScorecardBatchRequest struct { Repos []*Repo `protobuf:"bytes,4,rep,name=repos,proto3" json:"repos,omitempty"` ShardNum *int32 `protobuf:"varint,2,opt,name=shard_num,json=shardNum,proto3,oneof" json:"shard_num,omitempty"` JobTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=job_time,json=jobTime,proto3,oneof" json:"job_time,omitempty"` // contains filtered or unexported fields }
func (*ScorecardBatchRequest) Descriptor
deprecated
func (*ScorecardBatchRequest) Descriptor() ([]byte, []int)
Deprecated: Use ScorecardBatchRequest.ProtoReflect.Descriptor instead.
func (*ScorecardBatchRequest) GetJobTime ¶
func (x *ScorecardBatchRequest) GetJobTime() *timestamppb.Timestamp
func (*ScorecardBatchRequest) GetRepos ¶
func (x *ScorecardBatchRequest) GetRepos() []*Repo
func (*ScorecardBatchRequest) GetShardNum ¶
func (x *ScorecardBatchRequest) GetShardNum() int32
func (*ScorecardBatchRequest) ProtoMessage ¶
func (*ScorecardBatchRequest) ProtoMessage()
func (*ScorecardBatchRequest) ProtoReflect ¶
func (x *ScorecardBatchRequest) ProtoReflect() protoreflect.Message
func (*ScorecardBatchRequest) Reset ¶
func (x *ScorecardBatchRequest) Reset()
func (*ScorecardBatchRequest) String ¶
func (x *ScorecardBatchRequest) String() string
type ShardMetadata ¶
type ShardMetadata struct { ShardLoc *string `protobuf:"bytes,1,opt,name=shard_loc,json=shardLoc,proto3,oneof" json:"shard_loc,omitempty"` NumShard *int32 `protobuf:"varint,2,opt,name=num_shard,json=numShard,proto3,oneof" json:"num_shard,omitempty"` CommitSha *string `protobuf:"bytes,3,opt,name=commit_sha,json=commitSha,proto3,oneof" json:"commit_sha,omitempty"` // contains filtered or unexported fields }
func (*ShardMetadata) Descriptor
deprecated
func (*ShardMetadata) Descriptor() ([]byte, []int)
Deprecated: Use ShardMetadata.ProtoReflect.Descriptor instead.
func (*ShardMetadata) GetCommitSha ¶
func (x *ShardMetadata) GetCommitSha() string
func (*ShardMetadata) GetNumShard ¶
func (x *ShardMetadata) GetNumShard() int32
func (*ShardMetadata) GetShardLoc ¶
func (x *ShardMetadata) GetShardLoc() string
func (*ShardMetadata) ProtoMessage ¶
func (*ShardMetadata) ProtoMessage()
func (*ShardMetadata) ProtoReflect ¶
func (x *ShardMetadata) ProtoReflect() protoreflect.Message
func (*ShardMetadata) Reset ¶
func (x *ShardMetadata) Reset()
func (*ShardMetadata) String ¶
func (x *ShardMetadata) String() string
type ShardSummary ¶ added in v4.9.0
type ShardSummary struct {
// contains filtered or unexported fields
}
ShardSummary is a summary of information about a set of shards with the same creation time.
func (*ShardSummary) CreationTime ¶ added in v4.9.0
func (s *ShardSummary) CreationTime() time.Time
CreationTime returns the time the shards were created. This corresponds to the job time generated by the controller.
func (*ShardSummary) IsCompleted ¶ added in v4.9.0
func (s *ShardSummary) IsCompleted(completionThreshold float64) bool
IsCompleted checks if the percentage of completed shards is over the desired completion threshold. It also returns false to prevent transfers in cases where the expected number of shards is 0, as either the .shard_metadata file is missing, or there is nothing to transfer anyway.
func (*ShardSummary) IsTransferred ¶ added in v4.9.0
func (s *ShardSummary) IsTransferred() bool
IsTransferred returns true if the shards have already been transferred. A true value indicates that a transfer should not occur, a false value indicates that a transfer should occur if IsCompleted() also returns true.
func (*ShardSummary) MarkTransferred ¶ added in v4.9.0
func (s *ShardSummary) MarkTransferred(ctx context.Context, bucketURL string) error
func (*ShardSummary) Metadata ¶ added in v4.9.0
func (s *ShardSummary) Metadata() []byte
Metadata returns the raw metadata about the bucket.