All Projects → hashicorp → nomad-ruby

hashicorp / nomad-ruby

Licence: MPL-2.0 License
The official Ruby client for Nomad

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to nomad-ruby

XCMetricsAggregator
Automation tool for Xcode Metrics Organizer with AppleScript
Stars: ✭ 53 (+96.3%)
Mutual labels:  gem
nomad-consult-ansible-centos
Deploy nomad & consult on centos with ansible
Stars: ✭ 17 (-37.04%)
Mutual labels:  nomad
drone-nomad
Drone plugin for deployment with Nomad
Stars: ✭ 18 (-33.33%)
Mutual labels:  nomad
vim-hcl
Syntax highlighting for HashiCorp Configuration Language (HCL)
Stars: ✭ 83 (+207.41%)
Mutual labels:  nomad
yo-ruby
🌈 ✨ A super awesome Ruby wrapper of the Yo API.
Stars: ✭ 15 (-44.44%)
Mutual labels:  gem
JAlgoArena
JAlgoArena programming contest platform
Stars: ✭ 32 (+18.52%)
Mutual labels:  nomad
graphql-rails logger
Display GraphQL queries in a more readable format
Stars: ✭ 102 (+277.78%)
Mutual labels:  gem
nomad-toast
A tool for receiving notifications based on HashiCorp Nomad events.
Stars: ✭ 40 (+48.15%)
Mutual labels:  nomad
jquery-datatables
Jquery datatables ruby gems for assets pipeline
Stars: ✭ 73 (+170.37%)
Mutual labels:  gem
academic
Jekyll theme with a focus on simplicity, typography and flexibility
Stars: ✭ 71 (+162.96%)
Mutual labels:  gem
slow-down
A centralized Redis-based lock to help you wait on throttled resources
Stars: ✭ 21 (-22.22%)
Mutual labels:  gem
rack-simple user agent
Rack::SimpleUserAgent is stupidly simple UA detector
Stars: ✭ 13 (-51.85%)
Mutual labels:  gem
log-symbols
A ruby 💎gem💎 for generating log symbols
Stars: ✭ 14 (-48.15%)
Mutual labels:  gem
rspec n
A ruby gem that runs RSpec N times.
Stars: ✭ 37 (+37.04%)
Mutual labels:  gem
snapcrawl
Crawl a website and take screenshots
Stars: ✭ 37 (+37.04%)
Mutual labels:  gem
filtered
Filters ActiveRecord queries in a nice way
Stars: ✭ 28 (+3.7%)
Mutual labels:  gem
pretty trace
Love Your Ruby's Backtrace
Stars: ✭ 13 (-51.85%)
Mutual labels:  gem
arclight
A Rails engine supporting discovery of archival material
Stars: ✭ 25 (-7.41%)
Mutual labels:  gem
pwdcalc
Take no risk and help your users to choose good passwords!
Stars: ✭ 11 (-59.26%)
Mutual labels:  gem
enumerations
Better Rails Enumerations
Stars: ✭ 34 (+25.93%)
Mutual labels:  gem

Nomad Ruby Client

Nomad Ruby is the official Ruby client for interacting with Nomad by HashiCorp.

The documentation in this README corresponds to the master branch of the Nomad Ruby client. It may contain unreleased features or different APIs than the most recently released version. Please see the Git tag that corresponds to your version of the Nomad Ruby client for the proper documentation.

Quick Start

Install Ruby 2.4+: Guide.

Install via Rubygems:

$ gem install nomad

or add it to your Gemfile if you're using Bundler:

gem "nomad", "~> 0.1"

and then run the bundle command to install.

Connect to a Nomad API. For most API calls, it does not matter if you are connecting to a client or server node. In general, try to connect to the node with the lowest latency.

List all jobs in the system

Nomad.job.list
#=> []

Join the agent being queried to another agent

Nomad.agent.join("1.2.3.4")
#=> #<Nomad::AgentJoin:0x007fc40f9f60c0 @error=nil, @num_joined=1>

Create (run) a job (this must be a JSON job definition, not HCL)

Nomad.job.create(File.read("my-job.nomad"))
#=> #<Nomad::JobCreate:0x007fc40f9ac8a8
 @eval_create_index=11,
 @eval_id="7bd1a289-06b4-fc4a-5574-940ca4af6a8e",
 @index=11,
 @job_modify_index=10,
 @known_leader=true,
 @last_contact=0,
 @warnings=nil>

For more examples, return types, and possible errors, please see the YardDoc.

Internals & Normalization

Because Nomad's API is in active development, there are some inconsistencies in API responses. This client attempts to normalize those responses as best as possible. This includes providing utility classes for sizes, speed, and time that does conversion automatically.

Nomad::Duration

The Nomad::Duration class provides convenience functions for converting timestamps to different orders of magnitude.

evals = Nomad.evaluation.list
dur = evals[0].wait

dur
#=> #<Nomad::Duration:0x7fc4109d07e8 @duration="12s">

dur.seconds #=> 12.0
dur.milliseconds #=> 12_000.0
dur.days #=> 0.0001388888888888889

For more information and examples, see the YardDoc.

Nomad::Size

The Nomad::Size is used to covert metric sizes based on prefix, such as converting 1GB to MB.

job = Nomad.job.read("my-job")
disk = job.groups[0].ephemeral_disk

disk.size #=> #<Nomad::Size:0x7fc41213d340 @size="10MB">
disk.size.gigabytes #=> 0.01

For more information and examples, see the YardDoc.

Development

  1. Clone the project on GitHub
  2. Create a feature branch
  3. Submit a Pull Request

Important Notes:

  • All new features must include test coverage. At a bare minimum, Unit tests are required. It is preferred if you include acceptance tests as well.
  • The tests must be be idempotent. The HTTP calls made during a test should be able to be run over and over.
  • Tests are order independent. The default RSpec configuration randomizes the test order, so this should not be a problem.
  • Integration tests require Nomad Nomad must be available in the path for the integration tests to pass.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].