cache

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{

	&cli.StringFlag{
		Name:  "cache.driver",
		Usage: "driver to be used for the cache",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_CACHE_DRIVER"),
			cli.EnvVar("CACHE_DRIVER"),
			cli.File("/vela/cache/driver"),
		),
		Required: true,
	},
	&cli.StringFlag{
		Name:  "cache.addr",
		Usage: "fully qualified url (<scheme>://<host>) for the cache",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_CACHE_ADDR"),
			cli.EnvVar("CACHE_ADDR"),
			cli.File("/vela/cache/addr"),
		),
		Action: func(_ context.Context, _ *cli.Command, v string) error {

			if !strings.Contains(v, "://") {
				return fmt.Errorf("cache address must be fully qualified (<scheme>://<host>)")
			}

			if strings.HasSuffix(v, "/") {
				return fmt.Errorf("cache address must not have trailing slash")
			}

			return nil
		},
	},
	&cli.BoolFlag{
		Name:  "cache.cluster",
		Usage: "enables connecting to a cache cluster",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_CACHE_CLUSTER"),
			cli.EnvVar("CACHE_CLUSTER"),
			cli.File("/vela/cache/cluster"),
		),
	},
	&cli.StringFlag{
		Name:  "cache.install-token-key",
		Usage: "set cache install token key",
		Sources: cli.NewValueSourceChain(
			cli.EnvVar("VELA_CACHE_INSTALL_TOKEN_KEY"),
			cli.EnvVar("CACHE_INSTALL_TOKEN_KEY"),
			cli.File("/vela/cache/install_token_key"),
		),
		Required: true,
	},
}

Flags represents all supported command line interface (CLI) flags for the queue.

https://pkg.go.dev/github.com/urfave/cli?tab=doc#Flag

Functions

func WithGinContext

func WithGinContext(c *gin.Context, s Service)

WithGinContext inserts the cache Service into the gin.Context.

Types

type Service

type Service interface {

	// Driver defines a function that outputs
	// the configured queue driver.
	Driver() string

	StoreInstallToken(ctx context.Context, token *models.InstallToken, build int64, timeout int32) error
	GetInstallToken(ctx context.Context, token string) (*models.InstallToken, error)
	EvictInstallToken(ctx context.Context, token string) error
	EvictBuildInstallTokens(ctx context.Context, build int64) error

	StoreInstallStatusToken(ctx context.Context, build int64, token string) error
	GetInstallStatusToken(ctx context.Context, build int64) (string, error)
	EvictInstallStatusToken(ctx context.Context, build int64) error

	StorePermissionToken(ctx context.Context, installID int64, token string) error
	GetPermissionToken(ctx context.Context, installID int64) (string, error)
}

Service represents the interface for Vela integrating with the different supported Queue backends.

func FromCLICommand

func FromCLICommand(ctx context.Context, c *cli.Command) (Service, error)

FromCLICommand helper function to setup the queue from the CLI arguments.

func FromContext

func FromContext(c context.Context) Service

FromContext retrieves the cache Service from the context.Context.

func FromGinContext

func FromGinContext(c *gin.Context) Service

FromGinContext retrieves the cache Service from the gin.Context.

func New

func New(ctx context.Context, s *Setup) (Service, error)

New creates and returns a Vela service capable of integrating with the configured queue environment. Currently, the following queues are supported:

* redis .

type Setup

type Setup struct {

	// specifies the driver to use for the queue client
	Driver string
	// specifies the address to use for the queue client
	Address string
	// enables the queue client to integrate with a queue cluster
	Cluster bool

	InstallTokenKey string
}

Setup represents the configuration necessary for creating a Vela service capable of integrating with a configured queue environment.

func (*Setup) Redis

func (s *Setup) Redis(ctx context.Context) (Service, error)

Redis creates and returns a Vela service capable of integrating with a Redis queue.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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