writeback

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 19 Imported by: 8

Documentation

Overview

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor executes write back tasks.

func NewExecutor

func NewExecutor(
	stats tally.Scope,
	fs FileStore,
	backends *backend.Manager,
) *Executor

NewExecutor creates a new Executor.

func (*Executor) Exec

func (e *Executor) Exec(r persistedretry.Task) error

Exec uploads the cache file corresponding to r's digest to the remote backend that matches r's namespace.

func (*Executor) Name

func (e *Executor) Name() string

Name returns the executor name.

type FileStore

type FileStore interface {
	DeleteCacheFileMetadata(name string, md metadata.Metadata) error
	GetCacheFileReader(name string) (store.FileReader, error)
}

FileStore defines store operations required for write-back.

type NameQuery

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

NameQuery queries writeback tasks which match a name.

func NewNameQuery

func NewNameQuery(name string) *NameQuery

NewNameQuery returns a new NameQuery.

type Store

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

Store stores writeback tasks.

func NewStore

func NewStore(db *sqlx.DB) *Store

NewStore creates a new Store.

func (*Store) AddFailed

func (s *Store) AddFailed(r persistedretry.Task) error

AddFailed adds r as failed.

func (*Store) AddPending

func (s *Store) AddPending(r persistedretry.Task) error

AddPending adds r as pending.

func (*Store) Find

func (s *Store) Find(query interface{}) ([]persistedretry.Task, error)

Find finds tasks matching query.

func (*Store) GetFailed

func (s *Store) GetFailed() ([]persistedretry.Task, error)

GetFailed returns all failed tasks.

func (*Store) GetPending

func (s *Store) GetPending() ([]persistedretry.Task, error)

GetPending returns all pending tasks.

func (*Store) MarkFailed

func (s *Store) MarkFailed(r persistedretry.Task) error

MarkFailed marks r as failed.

func (*Store) MarkPending

func (s *Store) MarkPending(r persistedretry.Task) error

MarkPending marks r as pending.

func (*Store) Remove

func (s *Store) Remove(r persistedretry.Task) error

Remove removes r.

type Task

type Task struct {
	Namespace   string        `db:"namespace"`
	Name        string        `db:"name"`
	CreatedAt   time.Time     `db:"created_at"`
	LastAttempt time.Time     `db:"last_attempt"`
	Failures    int           `db:"failures"`
	Delay       time.Duration `db:"delay"`

	// Trace context for linking async execution back to original request.
	TraceID    string `db:"trace_id"`
	SpanID     string `db:"span_id"`
	TraceFlags string `db:"trace_flags"` // Hex string of trace flags (e.g., "01" if sampled)

	// Deprecated. Use name instead.
	Digest core.Digest `db:"digest"`
}

Task contains information to write back a blob to remote storage.

func NewTask

func NewTask(namespace, name string, delay time.Duration) *Task

NewTask creates a new Task. Deprecated: Use NewTaskWithContext to preserve trace context.

func NewTaskWithContext added in v0.1.20

func NewTaskWithContext(ctx context.Context, namespace, name string, delay time.Duration) *Task

NewTaskWithContext creates a new Task and captures the trace context from ctx. This allows the async writeback execution to be linked to the original request trace. It also captures TraceFlags to preserve the sampling decision.

func TaskFixture

func TaskFixture() *Task

TaskFixture returns a randomly generated Task for testing purposes.

func (*Task) GetFailures

func (t *Task) GetFailures() int

GetFailures returns the number of times t has failed.

func (*Task) GetLastAttempt

func (t *Task) GetLastAttempt() time.Time

GetLastAttempt returns when t was last attempted.

func (*Task) HasTraceContext added in v0.1.20

func (t *Task) HasTraceContext() bool

HasTraceContext returns true if the task has captured trace context.

func (*Task) Ready

func (t *Task) Ready() bool

Ready returns whether t is ready to run.

func (*Task) SpanContext added in v0.1.20

func (t *Task) SpanContext() trace.SpanContext

SpanContext reconstructs a trace.SpanContext from the stored trace IDs. Returns an invalid SpanContext if the task has no trace context or if parsing fails.

func (*Task) String

func (t *Task) String() string

func (*Task) Tags added in v0.1.2

func (t *Task) Tags() map[string]string

Tags is unused.

type TaskMatcher

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

TaskMatcher is a gomock Matcher which matches two tasks.

func MatchTask

func MatchTask(task *Task) *TaskMatcher

MatchTask returns a new TaskMatcher

func (*TaskMatcher) Matches

func (m *TaskMatcher) Matches(x interface{}) bool

Matches compares two tasks. It ignores checking for time.

func (*TaskMatcher) String

func (m *TaskMatcher) String() string

String returns the name of the matcher.

Jump to

Keyboard shortcuts

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