Class: Restate::Testing::RestateTestHarness
- Inherits:
-
Object
- Object
- Restate::Testing::RestateTestHarness
- Defined in:
- lib/restate/testing.rb
Overview
Manages the lifecycle of an SDK server and a Restate container for testing.
Instance Attribute Summary collapse
-
#admin_url ⇒ Object
readonly
Returns the value of attribute admin_url.
-
#ingress_url ⇒ Object
readonly
Returns the value of attribute ingress_url.
Instance Method Summary collapse
-
#initialize(*services, restate_image: 'docker.io/restatedev/restate:latest', always_replay: false, disable_retries: false) {|Endpoint| ... } ⇒ RestateTestHarness
constructor
A new instance of RestateTestHarness.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(*services, restate_image: 'docker.io/restatedev/restate:latest', always_replay: false, disable_retries: false) {|Endpoint| ... } ⇒ RestateTestHarness
Returns a new instance of RestateTestHarness.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/restate/testing.rb', line 56 def initialize(*services, restate_image: 'docker.io/restatedev/restate:latest', always_replay: false, disable_retries: false, &configure) @services = services @restate_image = restate_image @always_replay = always_replay @disable_retries = disable_retries @configure = configure @server_thread = nil @container = nil @port = nil @ingress_url = nil @admin_url = nil end |
Instance Attribute Details
#admin_url ⇒ Object (readonly)
Returns the value of attribute admin_url.
49 50 51 |
# File 'lib/restate/testing.rb', line 49 def admin_url @admin_url end |
#ingress_url ⇒ Object (readonly)
Returns the value of attribute ingress_url.
49 50 51 |
# File 'lib/restate/testing.rb', line 49 def ingress_url @ingress_url end |
Instance Method Details
#start ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/restate/testing.rb', line 73 def start @port = find_free_port endpoint = Restate.endpoint(*@services) @configure&.call(endpoint) rack_app = endpoint.app start_sdk_server(rack_app) wait_for_tcp(@port) start_restate_container register_sdk self rescue StandardError => e stop raise e end |
#stop ⇒ Object
88 89 90 91 |
# File 'lib/restate/testing.rb', line 88 def stop stop_restate_container stop_sdk_server end |