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
- Variables
- func GetEmulatorHostEnvVar(emulator Emulator) string
- func GetEmulatorHostEnvVarName(emulator Emulator) string
- func IsRunning(emulator Emulator) bool
- func SetEmulatorHostEnvVar(emulator Emulator) error
- func StartAdHocEmulatorInstanceAndSetEmulatorHostEnvVarBazelRBEOnly(emulator Emulator) error
- func StartAllEmulators() error
- func StartEmulatorIfNotRunning(emulator Emulator) (bool, error)
- func StopAllEmulators() error
- func UnsetAllEmulatorHostEnvVars() error
- type Emulator
Constants ¶
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 ¶
var AllEmulators = []Emulator{BigTable, CockroachDB, Datastore, Firestore, PubSub}
AllEmulators contains a list of all known emulators.
Functions ¶
func GetEmulatorHostEnvVar ¶
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 ¶
GetEmulatorHostEnvVarName returns the name of the *_EMULATOR_HOST environment variable corresponding to the given emulator.
func IsRunning ¶
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 ¶
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 ¶
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 ¶
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 UnsetAllEmulatorHostEnvVars ¶
func UnsetAllEmulatorHostEnvVars() error
UnsetAllEmulatorHostEnvVars unsets the *_EMULATOR_HOST environment variables for all known emulators.