Skip to content

Instantly share code, notes, and snippets.

View mdeniz's full-sized avatar

Moisés Déniz Alemán mdeniz

  • Las Palmas de Gran Canaria
View GitHub Profile
@mdeniz
mdeniz / benchmark_results.md
Last active January 9, 2018 16:07
JSON encode/decode benchmark Yajl vs ActiveSupport::JSON in actual OBS setup

Benchmarking Decode of JSON files

Decoding 1,000 times from small.json (13.3 KB)

user system total real
Yajl::Parser 0.240000 0.010000 0.250000 ( 0.250759)
ActiveSupport::JSON 0.230000 0.000000 0.230000 ( 0.229365)
@mdeniz
mdeniz / ESADO.md
Last active July 14, 2017 09:49
Event System Architectural Design Options

Event System Architectural Design Options

We have choosed 5 possible options that can be possible to implement.

Option 1 – Fully remove the Event representation

No more Event classes, no table needed in the database for storing Event's data. We will store the data needed inside the DelayedJob payload (doesn’t mean that the event data is stored as right now, just the data needed). Whenever the event happen jobs are created accordingly to:

Option #3: batched events are processed in multipurpose jobs

Everything stays as it is and we make sure each class of job runs in its own queue and never concurrently

  • We will migrate to ActiveJob instead of running jobs directly on DelayedJobs.
  • We are not going to be merging jobs into one for having more concentrated multipurpose jobs, so, lets keep things like they are right now.
  • Adding code for failures while processing events wil be also not in this proposal but will be something mandatory to implement.

As we agreed for this option on to not run the same job concurrently... to have at most one job enqueued is something we may introduce. Could be something like this in every place we create and enque a job:

JobClass.perform_later if Delayed::Job.where(queue: JobClass.queue_as).count.zero?
# this is to speed up secure Project.find
def self.forbidden_project_ids
# Admins don't have forbidden projects
return [0] if User.current && User.current.is_admin?
# This will cache and return an array:
# {projecs: [p1,p2], whitelist: { u1: [p1], u2: [p1,p2], u3: [p2] } }
forbidden_projects = Rails.cache.fetch('forbidden_projects') do
forbidden_projects_hash = {projects: [], whitelist: {}}
@mdeniz
mdeniz / project.rb
Last active December 15, 2015 15:10
RemoteProject and Project changes to manage them like same kind of objects
# Update this methods in the Project class
class Project
def is_remote?
false
end
# returns an object of project(local or remote) or raises an exception
def self.get_by_name(project_name, options = {})
project = find_by(name: project_name)
@mdeniz
mdeniz / omg.rb
Last active November 25, 2015 16:54 — forked from hennevogel/omg.rb
def get_build_flags(flag_type)
the_flags = {}
all_repositories = [nil].concat(main_object.repositories.map{|repo| repo.name})
all_architecture = [nil].concat(main_object.architectures)
all_repositories.each do |repository|
the_flags[repository] = []
all_architectures.each do |architecture|
architecture_id = architecture ? architecture.id : nil
flag = main_object.flags.with_repositories(repository).with_architectures(architecture_id).first
unless flag