Class: Seira::Db
- Inherits:
-
Object
- Object
- Seira::Db
- Includes:
- Commands
- Defined in:
- lib/seira/db.rb,
lib/seira/db/create.rb,
lib/seira/db/write_pgbouncer_yaml.rb
Defined Under Namespace
Classes: Create, WritePgbouncerYaml
Constant Summary collapse
- VALID_ACTIONS =
%w[ help create delete list restart connect ps kill analyze create-readonly-user psql table-sizes index-sizes vacuum unused-indexes unused-indices user-connections info alter-proxyuser-roles add configure write-pgbouncer-yaml ].freeze
- SUMMARY =
"Manage your Cloud SQL Postgres databases.".freeze
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(app:, action:, args:, context:) ⇒ Db
constructor
A new instance of Db.
- #primary_instance ⇒ Object
- #run ⇒ Object
Methods included from Commands
#gcloud, gcloud, kubectl, #kubectl, #tsh, tsh
Constructor Details
#initialize(app:, action:, args:, context:) ⇒ Db
Returns a new instance of Db.
22 23 24 25 26 27 |
# File 'lib/seira/db.rb', line 22 def initialize(app:, action:, args:, context:) @app = app @action = action @args = args @context = context end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
20 21 22 |
# File 'lib/seira/db.rb', line 20 def action @action end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
20 21 22 |
# File 'lib/seira/db.rb', line 20 def app @app end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
20 21 22 |
# File 'lib/seira/db.rb', line 20 def args @args end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
20 21 22 |
# File 'lib/seira/db.rb', line 20 def context @context end |
Instance Method Details
#primary_instance ⇒ Object
78 79 80 |
# File 'lib/seira/db.rb', line 78 def primary_instance Seira::Helpers.get_seira_app_config(context: context)['primary_sql_instance'] end |
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/seira/db.rb', line 29 def run case action when 'help' run_help when 'create' run_create when 'add' run_add when 'configure' run_configure when 'delete' run_delete when 'list' run_list when 'restart' run_restart when 'connect' run_connect when 'ps' run_ps when 'kill' run_kill when 'analyze' run_analyze when 'create-readonly-user' run_create_readonly_user when 'psql' run_psql when 'table-sizes' run_table_sizes when 'index-sizes' run_index_sizes when 'vacuum' run_vacuum when 'unused-indexes', 'unused-indices' run_unused_indexes when 'user-connections' run_user_connections when 'info' run_info when 'alter-proxyuser-roles' run_alter_proxyuser_roles when 'write-pgbouncer-yaml' run_write_pgbouncer_yaml else fail "Unknown command encountered" end end |