gitlab.com/postgres-ai/database-lab/v3@v3.0.3/pkg/config/global/config.go (about)

     1  /*
     2  2021 © Postgres.ai
     3  */
     4  
     5  // Package global provides access to the global Database Lab Engine configuration.
     6  package global
     7  
     8  import (
     9  	"gitlab.com/postgres-ai/database-lab/v3/internal/retrieval/engine/postgres/tools/defaults"
    10  )
    11  
    12  // Config contains global Database Lab configurations.
    13  type Config struct {
    14  	Database  Database  `yaml:"database"`
    15  	Engine    string    `yaml:"engine"`
    16  	Debug     bool      `yaml:"debug"`
    17  	Telemetry Telemetry `yaml:"telemetry"`
    18  }
    19  
    20  // Database contains default configurations of the managed database.
    21  type Database struct {
    22  	Username string `yaml:"username"`
    23  	DBName   string `yaml:"dbname"`
    24  }
    25  
    26  // User returns default Database username.
    27  func (d *Database) User() string {
    28  	if d.Username != "" {
    29  		return d.Username
    30  	}
    31  
    32  	return defaults.Username
    33  }
    34  
    35  // Name returns default Database name.
    36  func (d *Database) Name() string {
    37  	if d.DBName != "" {
    38  		return d.DBName
    39  	}
    40  
    41  	return defaults.DBName
    42  }
    43  
    44  // Telemetry contains configuration of Database Lab Engine telemetry.
    45  type Telemetry struct {
    46  	Enabled bool   `yaml:"enabled"`
    47  	URL     string `yaml:"url"`
    48  }
    49  
    50  // EngineProps contains internal Database Lab Engine properties.
    51  type EngineProps struct {
    52  	InstanceID    string
    53  	ContainerName string
    54  	EnginePort    uint
    55  }