Skip to content

peplum/template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Peplum::Template

Peplum::Template is a template project used for Peplum applications.

Implementation

  • Clone this repo:
    • $ git clone git@github.com:peplum/peplum-template.git
  • Remove current git repo:
    • $ rm -rf peplum-template/.git
  • Fill in template/application.rb.
  • Fill in template/application/payload.rb with the code you want to run in a distributed environment.
  • Replace template and Template references with your project name.

You should now be good to go!

Installation

$ cd peplum-template
$ bundle install

Usage

See the examples/ directory.

Grid

Peplum can run payloads from the same machine, but the idea behind it is to use a Grid which transparently load-balances and line-aggregates, in order to combine resources and perform batch operations faster than one single machine could.

That Grid technology is graciously provided by Cuboid and can be setup like so:

$ bundle exec irb
irb(main):001:0> require 'peplum/template'
=> true
irb(main):002:0> Peplum::Template::Application.spawn( :agent, address: Socket.gethostname )
I, [2023-05-21T19:11:20.772790 #359147]  INFO -- System: Logfile at: /home/zapotek/.cuboid/logs/Agent-359147-8499.log
I, [2023-05-21T19:11:20.772886 #359147]  INFO -- System: [PID 359147] RPC Server started.
I, [2023-05-21T19:11:20.772892 #359147]  INFO -- System: Listening on xps:8499

And at the terminal of another machine:

$ bundle exec irb
irb(main):001:0> require 'peplum/template'
=> true
irb(main):002:0> Peplum::Template::Application.spawn( :agent, address: Socket.gethostname, peer: 'xps:8499' )
I, [2023-05-21T19:12:38.897746 #359221]  INFO -- System: Logfile at: /home/zapotek/.cuboid/logs/Agent-359221-5786.log
I, [2023-05-21T19:12:38.998472 #359221]  INFO -- System: [PID 359221] RPC Server started.
I, [2023-05-21T19:12:38.998494 #359221]  INFO -- System: Listening on xps:5786

That's a Grid of 2 Peplum Agents, both of them available to provide worker Instances that can be used to parallelize execution.

If those 2 machines use a different pipe to a network you target, the result will be that the network resources are going to be in a way combined; or if the payload is too CPU intensive for just one machine, this will split the workload amongst the 2.

The cool thing is that it doesn't matter to which you refer for Instance spawning, the appropriate one is going to be the one providing it.

You can then configure the REST service to use any of those 2 Agents and perform your operation -- see examples/rest.rb.

The REST service is good for integration, so it's your safe bet; you can however also take advantage of the internal RPC protocol and opt for something more like examples/rpc.rb.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/peplum/peplum-template.

Funding

Peplum::Template is a Peplum project and as such funded by Ecsypno Single Member P.C..

About

A template project for Peplum applications.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors