Class: Mxrb::RubyApp::NativeBridge
- Inherits:
-
Object
- Object
- Mxrb::RubyApp::NativeBridge
- Defined in:
- lib/mxrb/ruby_app.rb
Overview
Owns the source MPR and its pure-Ruby interpreter for one application.
Instance Attribute Summary collapse
-
#access_control ⇒ Object
readonly
Returns the value of attribute access_control.
-
#interpreter ⇒ Object
readonly
Returns the value of attribute interpreter.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(path, database:, record_hooks: {}, adapters: {}, java_custom_actions: {}, allow_destructive: false, coordinator: nil, scheduler_lease_ttl: 300) ⇒ NativeBridge
constructor
A new instance of NativeBridge.
- #start_scheduler ⇒ Object
Constructor Details
#initialize(path, database:, record_hooks: {}, adapters: {}, java_custom_actions: {}, allow_destructive: false, coordinator: nil, scheduler_lease_ttl: 300) ⇒ NativeBridge
Returns a new instance of NativeBridge.
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
# File 'lib/mxrb/ruby_app.rb', line 805 def initialize(path, database:, record_hooks: {}, adapters: {}, java_custom_actions: {}, allow_destructive: false, coordinator: nil, scheduler_lease_ttl: 300) FileUtils.mkdir_p(File.dirname(database)) @project = Model::Project.open(path) @store = Runtime::SQLiteStore.new(@project, path: database, allow_destructive:) @access_control = Runtime::AccessControl.new(@project) @interpreter = Runtime::Native::Interpreter.new( @project, store: @store, policy: @access_control, adapters:, java_custom_actions: ) register_record_hooks(record_hooks) @scheduler = Runtime::Scheduler.new( @project, executor: ->(name, **) { @interpreter.call(name) }, coordinator:, lease_ttl: scheduler_lease_ttl ) rescue StandardError close raise end |
Instance Attribute Details
#access_control ⇒ Object (readonly)
Returns the value of attribute access_control.
803 804 805 |
# File 'lib/mxrb/ruby_app.rb', line 803 def access_control @access_control end |
#interpreter ⇒ Object (readonly)
Returns the value of attribute interpreter.
803 804 805 |
# File 'lib/mxrb/ruby_app.rb', line 803 def interpreter @interpreter end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
803 804 805 |
# File 'lib/mxrb/ruby_app.rb', line 803 def project @project end |
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
803 804 805 |
# File 'lib/mxrb/ruby_app.rb', line 803 def scheduler @scheduler end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
803 804 805 |
# File 'lib/mxrb/ruby_app.rb', line 803 def store @store end |
Instance Method Details
#close ⇒ Object
830 831 832 833 834 |
# File 'lib/mxrb/ruby_app.rb', line 830 def close scheduler&.shutdown store&.close project&.close end |
#start_scheduler ⇒ Object
825 826 827 828 |
# File 'lib/mxrb/ruby_app.rb', line 825 def start_scheduler scheduler.start unless scheduler.jobs.empty? scheduler end |