Legion Extensions Home
Developing a LEX
LEXs are the only reason Legion as a framework is vaulable. They are designed to be easy to create without the overhead of managing things like workers, threads, queues, data connections, etc.
LEX folder structure
lib/legion
name(http)
version.rb
actors(optional)
http.rb
runners(required)
http.rb
foobar.rb
transport(optional)
data(optional)
http.rb (the bootstrap file)
Example bootstrap
require 'legion/extensions/http/version'
require 'legion/extensions'
module Legion
module Extensions
module Http
extend Legion::Extensions::Core
end
end
end
When you create a runner, it is recommended to use the lex helper as it will give you some base functionality that will come in hand
module Legion::Extensions::Http:Runners
module Http
include Legion::Extensions::Helpers::Lex
end
end
Â
LEX Data::Migrations
Legion automatically handles database schema migrations for a lex. All you need to do is create this folder structure legion/extensions/http/data/migrations/
Migration files should be formatted as 001_text_desc.rb
The Legion framework will handling making sure your schema is up to date. If you update a LEX gem that has new migrations, next time you start Legion with that newer version, it will be upgraded automatically.
Â
LEX Data::Models
You can also add custom models in the case where you are adding new tables that aren’t default.
Model files should be located at legion/extensions/http/data/models and the models must extend Sequel::Model
otherwise bad things will happen
Example
module Legion::Extensions::Scheduler::Data::Model
class Schedule < Sequel::Model
one_to_many :schedule_logs
many_to_one :task
many_to_one :function
end
end
Models that are created from a LEX are not registered globally as you cannot guarantee that the lex is installed for all workers.