Fixer Client
Client gem for the Fixer application.
Installation
Add this line to your application's Gemfile:
gem 'fixer_client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install fixer_client
Usage
You need to configure the client credentials:
require 'fixer_client'
# by default it will get credentials from ENV
puts ENV['FIXER_CLIENT_ID'] + " is the id"
puts ENV['FIXER_CLIENT_SECRET'] + " is the secret"
# or set them explicitly
Fixer.configure do |c|
c.client_id = ''
c.client_secret = ''
c.endpoint = 'http://fixer.prx.dev/api/' # default
end
Once configured, you can use the client to access jobs and tasks:
require 'fixer_client'
client = Fixer::Client.new
# list jobs
js = client.jobs.list
# get a particular job by id
j = client.jobs.get('some-job-id')
# update a job
j = client.jobs.update(j)
# create a job
job = {
job: {
job_type: 'test',
priority: 1,
retry_max: 10,
retry_delay: 300,
tasks: [
{
task_type: 'echo',
label: 'test1',
options: { foo: 'bar' },
call_back: 'http://cms.prx.dev/call_back'
}
]
}
}
j = client.jobs.create(job)
You can also create jobs by dropping them on an SQS queue (assuming your fixer server is so configured):
See the examples/sqs_client.rb
:
Fixer.configure do |c|
# required: client_id identifies the application for this job
c.client_id = ''
c.client_secret = ''
# this is the default value
c.queue = 'production_fixer_job_create'
# optional: aws-sdk-core gem's config can be ENV vars, or in Fixer
c.aws = {
access_key_id: '',
secret_access_key: '',
region: 'us-east-1'
}
end
client = Fixer::SqsClient.new
job = {
job: {
original: 's3://test-fixer/audio.wav',
job_type: 'audio',
tasks: [
{
task_type: 'transcode',
options: { format: 'mp3', bit_rate: 64, sample_rate: 44100 },
result: 's3://test-fixer/audio.mp3'
}
]
}
}
# if not present, id is assigned to a GUID before sending to SQS
new_job = client.create_job(job)
puts "new job created with id: #{new_job.id}"
License
Contributing
In a local development environment, you can use a .env-fixer_client
file that will be loaded to set the required environment variables.
For example:
touch .env-fixer_client
echo FIXER_CLIENT_ID=1111111111111111111111111111111111111111111111111111111111111111 >> .env-fixer_client
echo FIXER_CLIENT_SECRET=2222222222222222222222222222222222222222222222222222222222222222 >> .env-fixer_client
# you can also set useful values like this for debugging
echo EXCON_DEBUG=true
- Fork it ( https://github.com/[my-github-username]/fixer_client/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request