queue

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Package queue provides the ability for Vela to integrate with different supported Queue backends.

Usage:

import "github.com/go-vela/pkg-queue/queue"

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{

	&cli.StringFlag{
		EnvVars: []string{"VELA_QUEUE_LOG_FORMAT", "QUEUE_LOG_FORMAT", "VELA_LOG_FORMAT"},
		Name:    "queue.log.format",
		Usage:   "format of logs to output",
		Value:   "json",
	},
	&cli.StringFlag{
		EnvVars: []string{"VELA_QUEUE_LOG_LEVEL", "QUEUE_LOG_LEVEL", "VELA_LOG_LEVEL"},
		Name:    "queue.log.level",
		Usage:   "level of logs to output",
		Value:   "info",
	},

	&cli.StringFlag{
		EnvVars: []string{"VELA_QUEUE_DRIVER", "QUEUE_DRIVER"},
		Name:    "queue.driver",
		Usage:   "driver to be used for the queue",
	},
	&cli.StringFlag{
		EnvVars: []string{"VELA_QUEUE_ADDR", "QUEUE_ADDR"},
		Name:    "queue.addr",
		Usage:   "fully qualified url (<scheme>://<host>) for the queue",
	},
	&cli.BoolFlag{
		EnvVars: []string{"VELA_QUEUE_CLUSTER", "QUEUE_CLUSTER"},
		Name:    "queue.cluster",
		Usage:   "enables connecting to a queue cluster",
	},
	&cli.StringSliceFlag{
		EnvVars: []string{"VELA_QUEUE_ROUTES", "QUEUE_ROUTES"},
		Name:    "queue.routes",
		Usage:   "list of routes (channels/topics) to publish builds",
		Value:   cli.NewStringSlice(constants.DefaultRoute),
	},
	&cli.DurationFlag{
		EnvVars: []string{"VELA_QUEUE_POP_TIMEOUT", "QUEUE_POP_TIMEOUT"},
		Name:    "queue.pop.timeout",
		Usage:   "timeout for requests that pop items off the queue",
		Value:   60 * time.Second,
	},
}

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 WithContext

func WithContext(c context.Context, s Service) context.Context

WithContext inserts the queue Service into the context.Context.

func WithGinContext

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

WithGinContext inserts the queue Service into the gin.Context.

Types

type Service

type Service interface {

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

	// Pop defines a function that grabs an
	// item off the queue.
	Pop(context.Context) (*types.Item, error)

	// Push defines a function that publishes an
	// item to the specified route in the queue.
	Push(context.Context, string, []byte) error

	// Route defines a function that decides which
	// channel a build gets placed within the queue.
	Route(*pipeline.Worker) (string, error)
}

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

func FromContext

func FromContext(c context.Context) Service

FromContext retrieves the queue Service from the context.Context.

func FromGinContext

func FromGinContext(c *gin.Context) Service

FromGinContext retrieves the queue Service from the gin.Context.

func New

func New(s *Setup) (Service, error)

nolint: godot // ignore period at end for comment ending in a list

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
	// specifies a list of routes (channels/topics) for managing builds for the queue client
	Routes []string
	// specifies the timeout for pop requests for the queue client
	Timeout time.Duration
}

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

func (*Setup) Kafka

func (s *Setup) Kafka() (Service, error)

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

func (*Setup) Redis

func (s *Setup) Redis() (Service, error)

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

func (*Setup) Validate

func (s *Setup) Validate() error

Validate verifies the necessary fields for the provided configuration are populated correctly.

Directories

Path Synopsis
Package redis provides the ability for Vela to integrate with a Redis server as a queue backend.
Package redis provides the ability for Vela to integrate with a Redis server as a queue backend.

Jump to

Keyboard shortcuts

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