Class: Muxi::ServerClient
- Inherits:
-
Object
- Object
- Muxi::ServerClient
- Defined in:
- lib/muxi/server_client.rb
Instance Method Summary collapse
- #cancel_update(formation_id) ⇒ Object
- #delete_formation(formation_id) ⇒ Object
- #deploy_formation(formation_id, payload) ⇒ Object
-
#deploy_formation_stream(formation_id, payload, &block) ⇒ Object
Streaming.
- #get_formation(formation_id) ⇒ Object
- #get_formation_logs(formation_id, limit: nil) ⇒ Object
- #get_server_logs(limit: nil) ⇒ Object
- #health ⇒ Object
-
#initialize(config = nil, **kwargs) ⇒ ServerClient
constructor
A new instance of ServerClient.
- #list_formations ⇒ Object
-
#ping ⇒ Object
Unauthenticated.
- #restart_formation(formation_id) ⇒ Object
- #restart_formation_stream(formation_id, &block) ⇒ Object
- #rollback_formation(formation_id) ⇒ Object
- #rollback_formation_stream(formation_id, &block) ⇒ Object
- #start_formation(formation_id) ⇒ Object
- #start_formation_stream(formation_id, &block) ⇒ Object
-
#status ⇒ Object
Authenticated - Server management.
- #stop_formation(formation_id) ⇒ Object
- #stream_formation_logs(formation_id, &block) ⇒ Object
- #update_formation(formation_id, payload) ⇒ Object
- #update_formation_stream(formation_id, payload, &block) ⇒ Object
Constructor Details
#initialize(config = nil, **kwargs) ⇒ ServerClient
Returns a new instance of ServerClient.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/muxi/server_client.rb', line 20 def initialize(config = nil, **kwargs) cfg = config || ServerConfig.new(**kwargs) @transport = Transport.new( base_url: cfg.url, key_id: cfg.key_id, secret_key: cfg.secret_key, timeout: cfg.timeout, max_retries: cfg.max_retries, debug: cfg.debug, logger: cfg.logger, app: cfg._app ) end |
Instance Method Details
#cancel_update(formation_id) ⇒ Object
77 78 79 |
# File 'lib/muxi/server_client.rb', line 77 def cancel_update(formation_id) rpc_post("/rpc/formations/#{formation_id}/cancel-update", {}) end |
#delete_formation(formation_id) ⇒ Object
73 74 75 |
# File 'lib/muxi/server_client.rb', line 73 def delete_formation(formation_id) rpc_delete("/rpc/formations/#{formation_id}") end |
#deploy_formation(formation_id, payload) ⇒ Object
81 82 83 |
# File 'lib/muxi/server_client.rb', line 81 def deploy_formation(formation_id, payload) rpc_post("/rpc/formations/#{formation_id}/deploy", payload) end |
#deploy_formation_stream(formation_id, payload, &block) ⇒ Object
Streaming
100 101 102 |
# File 'lib/muxi/server_client.rb', line 100 def deploy_formation_stream(formation_id, payload, &block) stream_sse("/rpc/formations/#{formation_id}/deploy/stream", body: payload, &block) end |
#get_formation(formation_id) ⇒ Object
53 54 55 |
# File 'lib/muxi/server_client.rb', line 53 def get_formation(formation_id) rpc_get("/rpc/formations/#{formation_id}") end |
#get_formation_logs(formation_id, limit: nil) ⇒ Object
89 90 91 92 |
# File 'lib/muxi/server_client.rb', line 89 def get_formation_logs(formation_id, limit: nil) params = limit ? { limit: limit } : nil rpc_get("/rpc/formations/#{formation_id}/logs", params: params) end |
#get_server_logs(limit: nil) ⇒ Object
94 95 96 97 |
# File 'lib/muxi/server_client.rb', line 94 def get_server_logs(limit: nil) params = limit ? { limit: limit } : nil rpc_get("/rpc/server/logs", params: params) end |
#health ⇒ Object
40 41 42 |
# File 'lib/muxi/server_client.rb', line 40 def health @transport.request_json("GET", "/health") end |
#list_formations ⇒ Object
49 50 51 |
# File 'lib/muxi/server_client.rb', line 49 def list_formations rpc_get("/rpc/formations") end |
#ping ⇒ Object
Unauthenticated
35 36 37 38 |
# File 'lib/muxi/server_client.rb', line 35 def ping resp = @transport.request_json("GET", "/ping") resp.is_a?(Hash) ? resp.size : 0 end |
#restart_formation(formation_id) ⇒ Object
65 66 67 |
# File 'lib/muxi/server_client.rb', line 65 def restart_formation(formation_id) rpc_post("/rpc/formations/#{formation_id}/restart", {}) end |
#restart_formation_stream(formation_id, &block) ⇒ Object
112 113 114 |
# File 'lib/muxi/server_client.rb', line 112 def restart_formation_stream(formation_id, &block) stream_sse("/rpc/formations/#{formation_id}/restart/stream", body: {}, &block) end |
#rollback_formation(formation_id) ⇒ Object
69 70 71 |
# File 'lib/muxi/server_client.rb', line 69 def rollback_formation(formation_id) rpc_post("/rpc/formations/#{formation_id}/rollback", {}) end |
#rollback_formation_stream(formation_id, &block) ⇒ Object
116 117 118 |
# File 'lib/muxi/server_client.rb', line 116 def rollback_formation_stream(formation_id, &block) stream_sse("/rpc/formations/#{formation_id}/rollback/stream", body: {}, &block) end |
#start_formation(formation_id) ⇒ Object
61 62 63 |
# File 'lib/muxi/server_client.rb', line 61 def start_formation(formation_id) rpc_post("/rpc/formations/#{formation_id}/start", {}) end |
#start_formation_stream(formation_id, &block) ⇒ Object
108 109 110 |
# File 'lib/muxi/server_client.rb', line 108 def start_formation_stream(formation_id, &block) stream_sse("/rpc/formations/#{formation_id}/start/stream", body: {}, &block) end |
#status ⇒ Object
Authenticated - Server management
45 46 47 |
# File 'lib/muxi/server_client.rb', line 45 def status rpc_get("/rpc/server/status") end |
#stop_formation(formation_id) ⇒ Object
57 58 59 |
# File 'lib/muxi/server_client.rb', line 57 def stop_formation(formation_id) rpc_post("/rpc/formations/#{formation_id}/stop", {}) end |
#stream_formation_logs(formation_id, &block) ⇒ Object
120 121 122 |
# File 'lib/muxi/server_client.rb', line 120 def stream_formation_logs(formation_id, &block) stream_sse("/rpc/formations/#{formation_id}/logs/stream", &block) end |
#update_formation(formation_id, payload) ⇒ Object
85 86 87 |
# File 'lib/muxi/server_client.rb', line 85 def update_formation(formation_id, payload) rpc_post("/rpc/formations/#{formation_id}/update", payload) end |
#update_formation_stream(formation_id, payload, &block) ⇒ Object
104 105 106 |
# File 'lib/muxi/server_client.rb', line 104 def update_formation_stream(formation_id, payload, &block) stream_sse("/rpc/formations/#{formation_id}/update/stream", body: payload, &block) end |