emulators

package
v0.0.0-...-33de393 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package emulators contains functions to start and stop emulators, and utilities to work with the various *_EMULATOR_HOST environment variables.

Unless otherwise specified, all functions in this package assume that there will be at most one instance of each emulator running at any given time.

Index

Constants

View Source
const (
	// BigTable represents a Google Cloud BigTable emulator.
	BigTable = Emulator("BigTable")

	// CockroachDB represents a test-only CockroachDB instance.
	CockroachDB = Emulator("CockroachDB")

	// Datastore represents a Google Cloud Datastore emulator.
	Datastore = Emulator("Datastore")

	// Firestore represents a Google Cloud Firestore emulator.
	Firestore = Emulator("Firestore")

	// PubSub represents a Google Cloud PubSub emulator.
	PubSub = Emulator("PubSub")
)

Variables

AllEmulators contains a list of all known emulators.

Functions

func GetEmulatorHostEnvVar

func GetEmulatorHostEnvVar(emulator Emulator) string

GetEmulatorHostEnvVar returns the contents of the *_EMULATOR_HOST environment variable corresponding to the given emulator, or the empty string if the environment variable is unset.

func GetEmulatorHostEnvVarName

func GetEmulatorHostEnvVarName(emulator Emulator) string

GetEmulatorHostEnvVarName returns the name of the *_EMULATOR_HOST environment variable corresponding to the given emulator.

func IsRunning

func IsRunning(emulator Emulator) bool

IsRunning returns true is the given emulator was started, or false if it hasn't been started or if it's been stopped.

func SetEmulatorHostEnvVar

func SetEmulatorHostEnvVar(emulator Emulator) error

SetEmulatorHostEnvVar sets the *_EMULATOR_HOST environment variable for the given emulator to point to an emulator instance started via StartEmulatorIfNotRunning.

It's OK to call this function before calling StartEmulatorIfNotRunning because both functions look up the emulator information (e.g. TCP port) from a package-private, global dictionary.

func StartAdHocEmulatorInstanceAndSetEmulatorHostEnvVarBazelRBEOnly

func StartAdHocEmulatorInstanceAndSetEmulatorHostEnvVarBazelRBEOnly(emulator Emulator) error

StartAdHocEmulatorInstanceAndSetEmulatorHostEnvVarBazelRBEOnly starts a new instance of the given emulator, regardless of whether a previous instance was already started, and sets the corresponding *_EMULATOR_HOST environment variable to point to the newly started instance. Any emulator instances started via this function will be ignored by StartEmulatorIfNotRunning.

This only works under RBE because under RBE, emulators are assigned an unused TCP port chosen by the operating system, which makes it possible to run multiple instances of the same emulator in parallel (e.g. one instance started via this function, and another one started via StartEmulatorIfNotRunning). This function will panic if called outside of RBE.

func StartAllEmulators

func StartAllEmulators() error

StartAllEmulators starts all known emulators.

func StartEmulatorIfNotRunning

func StartEmulatorIfNotRunning(emulator Emulator) (bool, error)

StartEmulatorIfNotRunning starts an emulator if it's not already running. Returns true if it started the emulator, or false if the emulator was already running.

func StopAllEmulators

func StopAllEmulators() error

StopAllEmulators stops all known emulators.

func UnsetAllEmulatorHostEnvVars

func UnsetAllEmulatorHostEnvVars() error

UnsetAllEmulatorHostEnvVars unsets the *_EMULATOR_HOST environment variables for all known emulators.

Types

type Emulator

type Emulator string

Emulator represents a Google Cloud emulator, a test-only CockroachDB server, etc.

Jump to

Keyboard shortcuts

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