region

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Description: This file contains the read through cache implementation for this package.

Description: This code contains cloud interface specific code

Description: This file contains the custom cloud code

Package region implements cloud region specific functionality Namely it implements a way to determine the "nearest" region to the current client.

Description: This file contains the GCP cloud code.

Description: This file contains region specific type definitions and region logic.

Index

Constants

View Source
const (
	// CloudGCP is the Google Cloud
	CloudGCP CloudName = "gcp"

	// RegionGCPUS is a multi-region region for all of the US
	RegionGCPUS Name = "us"

	// RegionGCPUS is a multi-region region for all of Europe
	RegionGCPEurope Name = "europe"

	// RegionGCPUS is a multi-region region for all of Asia
	RegionGCPAsia Name = "asia"
)

Variables

View Source
var (
	// RegionCachePath is the $HOME/<RegionCachePath> location of the regionpicker cache
	RegionCachePath = filepath.Join(".outreach", ".cache", "box")
	// RegionCacheFile is the name of the regionpicker cache file
	RegionCacheFile = "regions.json"
)

Functions

This section is empty.

Types

type Cloud

type Cloud interface {
	Regions(ctx context.Context) Regions
}

Cloud is an interface that returns regions exposed by a cloud

func CloudFromCloudName

func CloudFromCloudName(cloud CloudName) Cloud

CloudFromCloudName returns a cloud from a provided cloud name

type CloudName

type CloudName string

CloudName is a cloud that's able to be discovered

const (
	// CloudCustom is a custom cloud created by NewCustomCloud
	CloudCustom CloudName = "custom"
)

type CustomCloud

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

CustomCloud is a cloud that can take arbitrary regions

func NewCustomCloud

func NewCustomCloud(regions []*CustomRegion) *CustomCloud

NewCustomCloud creates a new CustomCloud with the provided regions

func (*CustomCloud) Regions

func (cc *CustomCloud) Regions(ctx context.Context) Regions

Regions converts the underlying region list into Regions

type CustomRegion

type CustomRegion struct {
	// Name is a region name
	Name Name

	// Endpoint is an endpoint to HEAD to determine the latency of this region
	Endpoint string
}

CustomRegion is a region that can be passed to NewCustomCloud to create a custom cloud with specific options.

type GCP

type GCP struct{}

GCP is a Google Cloud implementation of the interface Cloud

func (*GCP) Regions

func (*GCP) Regions(ctx context.Context) Regions

Regions returns a list of all known-gcp regions. This should not be used over native GCP region fetching. IDEA: One day we could probably get this from GCP. That is authenticated though.

type Name

type Name string

Name is the name of region

type Regions

type Regions []region

Regions is a list of regions

func (Regions) Filter

func (regions Regions) Filter(allowed []Name) Regions

func (Regions) Nearest

func (regions Regions) Nearest(ctx context.Context, logger logrus.FieldLogger) (Name, error)

Nearest returns the nearest region to the current caller based on latency of a HEAD request to all region's endpoints.

Jump to

Keyboard shortcuts

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