PeanutButter
Loading...
Searching...
No Matches
PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T > Class Template Referenceabstract

MySql flavor of TempDb. More...

Inheritance diagram for PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >:
PeanutButter.TempDb.TempDB< TDatabaseConnection > PeanutButter.TempDb.ITempDB PeanutButter.TempDb.MySql.Connector.TempDBMySql PeanutButter.TempDb.MySql.Data.TempDBMySql

Classes

class  MySqlVersionInfo

Public Member Functions

 TempDBMySqlBase (params string[] creationScripts)
 Construct a TempDbMySql with zero or more creation scripts and default options.
 TempDBMySqlBase (TempDbMySqlServerSettings settings, params string[] creationScripts)
 Create a TempDbMySql instance with provided options and zero or more creation scripts.
 TempDBMySqlBase (TempDbMySqlServerSettings settings, Action< object > beforeInit, params string[] creationScripts)
 Create a TempDbMySql instance with provided options, an action to run before initializing and zero or more creation scripts.
string Snapshot ()
 Snapshots the database and returns the path on disk.
string Snapshot (string toNewFolder)
 Snapshots the database to the provided path and returns the path on disk.
string Snapshot (string toNewFolder, bool restartServerAfterwards)
 LogSource (string name, string[] lines)
 LogSource (string name, string content)
void CloseAllConnections ()
override string DumpSchema ()
 (Where supported) dumps the current schema of the running database Currently only supported on mysql, when mysqldump is available
void SwitchToSchema (string schema)
 Switches to the provided schema name for connections from now on. Creates the schema if not already present.
void CreateSchemaIfNotExists (string schema)
void CreateUser (string user, string password, params string[] forSchemas)
void GrantAllPermissionsFor (string user, string schema, string host)
string Escape (string other)
 Escapes back-ticks in mysql sql strings.
string Quote (string other)
void Execute (string sql)
 Executes arbitrary sql on the current schema.
IEnumerable< Dictionary< string, object > > ExecuteReader (string sql)
override void Dispose ()
void Restart ()
override DbConnection OpenConnection ()
 Opens a new connection to the TempDb instance with the connection string automatically set based on the current running parameters.
override string ToString ()
Public Member Functions inherited from PeanutButter.TempDb.TempDB< TDatabaseConnection >
 TempDB (params string[] creationScripts)
 TempDB (Action< object > beforeInit, params string[] creationScripts)
string DumpSchema ()
 (Where supported) dumps the current schema of the running database Currently only supported on mysql, when mysqldump is available
void SetupAutoDispose (TimeSpan absoluteTimeout)
 Set up automatic disposal of this TempDb instance (may only be done once per instance)
void SetupAutoDispose (TimeSpan? absoluteTimeout, TimeSpan? inactivityTimeout)
 Set up automatic disposal of this TempDb instance (may only be done once per instance)
int TryFetchCurrentConnectionCount ()
DbConnection CreateConnection ()
void RunScripts (IEnumerable< string > scripts)
void DisposeManagedConnections ()
 Close and dispose of any connections which were created by OpenConnection()

Static Public Attributes

static int DefaultStartupMaxWaitSeconds = 45
 The maximum amount of time to wait for a mysqld process to be listening for connections after starting up. Defaults to 45 seconds, but left static so consumers can tweak the value as required.
static int MaxStartupAttempts = 5
 Maximum number of times that TempDBMySql will automatically re-attempt initial start. This may be useful in the case where MySql isn't starting up but also isn't logging anything particularly useful about why it isn't starting up. Defaults to 5, but left as a static so consumers can tweak the value as required.

Protected Member Functions

override void CreateDatabase ()
virtual bool IsMyInstance (Guid? assimilatedInstanceId)
bool CanConnect ()
virtual int FindRandomOpenPort ()
Protected Member Functions inherited from PeanutButter.TempDb.TempDB< TDatabaseConnection >
virtual void Init (string[] creationScripts)
int FetchCurrentConnectionCount ()
void CheckForInactivity (object _)
void Log (string message, params object[] parameters)
 Provides a convenience logging mechanism which outputs via the established LogAction.
virtual string GenerateConnectionString ()
void CreateDatabase ()
virtual void DeleteTemporaryDataArtifacts ()

Static Protected Member Functions

static void BeforeInit (TempDBMySqlBase< T > self, Action< object > beforeInit, TempDbMySqlServerSettings settings)

Protected Attributes

string SchemaName

Properties

string BootstrappedFromTemplateFolder [get, protected set]
string ServerCommandline [get]
static int MaxSecondsToWaitForMySqlToStart [get]
string ConfigFilePath [get, set]
 After the server has been set up and started, this will reflect the absolute path to the configuration file for the server.
bool VerboseLoggingEnabled [get, set]
TempDbMySqlServerSettings Settings [get]
 Set to true to see trace logging about discovery of a port to instruct mysqld to bind to.
int? ServerProcessId [get]
string ServerProcessCommand [get]
int Port [get, protected set]
bool RootPasswordSet [get]
Guid InstanceId [get]
MySqlVersionInfo MySqlVersion [get]
bool TemplateFolderIsShared [get]
string Name [get]
string Content [get]
bool IsRunning [get]
string DataDir [get]
string Platform [get, set]
Version Version [get, set]
Properties inherited from PeanutButter.TempDb.TempDB< TDatabaseConnection >
uint DefaultTimeout = 30 [get, set]
TempDbDisposedEventHandler Disposed [get, set]
 Fired when the instance is disposed. Useful if you've set up automatic disposal and would like to act on that.
bool KeepTemporaryDatabaseArtifactsForDiagnostics [get, set]
string DatabasePath [get, set]
 Path to where the temporary database resides. May be a file for single-file databases or a folder.
string ConnectionString [get]
Action< string > LogAction [get, set]
static string[] UndeletedArtifacts [get]

Detailed Description

MySql flavor of TempDb.

Type Constraints
T :DbConnection 

Member Function Documentation

◆ Dispose()

override void PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.Dispose ( )
virtual

◆ DumpSchema()

override string PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.DumpSchema ( )

(Where supported) dumps the current schema of the running database Currently only supported on mysql, when mysqldump is available

Returns

Implements PeanutButter.TempDb.ITempDB.

◆ Escape()

string PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.Escape ( string other)

Escapes back-ticks in mysql sql strings.

Parameters
other
Returns

◆ Execute()

void PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.Execute ( string sql)

Executes arbitrary sql on the current schema.

Parameters
sql

◆ OpenConnection()

override DbConnection PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.OpenConnection ( )
virtual

Opens a new connection to the TempDb instance with the connection string automatically set based on the current running parameters.

Returns

Reimplemented from PeanutButter.TempDb.TempDB< TDatabaseConnection >.

◆ Snapshot() [1/2]

string PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.Snapshot ( )

Snapshots the database and returns the path on disk.

  • will stop the server to snapshot and then restart the server afterwards
Returns

◆ Snapshot() [2/2]

string PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.Snapshot ( string toNewFolder)

Snapshots the database to the provided path and returns the path on disk.

  • will stop the server to snapshot and then restart the server afterwards
Returns

◆ SwitchToSchema()

void PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.SwitchToSchema ( string schema)

Switches to the provided schema name for connections from now on. Creates the schema if not already present.

Parameters
schema

◆ TempDBMySqlBase() [1/3]

PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.TempDBMySqlBase ( params string[] creationScripts)

Construct a TempDbMySql with zero or more creation scripts and default options.

Parameters
creationScripts

◆ TempDBMySqlBase() [2/3]

PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.TempDBMySqlBase ( TempDbMySqlServerSettings settings,
Action< object > beforeInit,
params string[] creationScripts )

Create a TempDbMySql instance with provided options, an action to run before initializing and zero or more creation scripts.

Parameters
settings
beforeInit
creationScripts

◆ TempDBMySqlBase() [3/3]

PeanutButter.TempDb.MySql.Base.TempDBMySqlBase< T >.TempDBMySqlBase ( TempDbMySqlServerSettings settings,
params string[] creationScripts )

Create a TempDbMySql instance with provided options and zero or more creation scripts.

Parameters
settings
creationScripts

The documentation for this class was generated from the following file:
  • source/TempDb/PeanutButter.TempDb.MySql.Base/TempDbMySqlBase.cs