Ilya Bylich

Page 2


Experimental MySQL HTTP API and Ruby

Yes, MySQL has an HTTP API which is:

  1. an experimental feature
  2. it ships as a native plugin only for 5.7 version (http://labs.mysql.com/?id=3)

Basically, it allows you to work with your database in the following ways:

  1. as an SQL endpoint
  2. as a CRUD endpoint
  3. as a JSON document endpoint

SQL endpoint

It gives an ability to run queries like

GET http://host:port/sql/:database/:query

For example

GET http://localhost:8080/sql/testdb/SELECT+1

is a synonym of SQL’s SELECT 1.

CRUD endpoint

Interface is:

GET http://host:port/crud/:database/:table/:id

And

GET http://localhost:8080/crud/test_db/test_table/101'

produces:

SELECT * FROM `test_db`.`test_table` WHERE `test_table`.`id` = 101

JSON document endpoint

Basically, with this endpoint your table has only 3 fields:

mysql> describe test_db.test_table;
+--------+---------------------+------+-----+---------+-------+
| Field  |
...

Continue reading →


ExceptionManager gem

ExceptionManager is a gem for getting extra information from your exception.

Source code: https://github.com/iliabylich/exception_manager

With this gem every time when you get an exception, it’s possible to grab subject of exception (the instance of class where raise happened), locals - local variables, subject_instance_variables and subject_class_variables

Examples:

require 'exception_manager'
ExceptionManager.enable!

class TestClassThatRaisesException
  @@class_variable = :class_value

  def test_error(*args)
    @instance_variable = :instance_value

    raise 'Test error'
  end
end

begin
  TestClassThatRaisesException.new.test_error(1, 2, 3)
rescue => e
  puts "Subject: {e.subject}"
  puts "Locals: {e.locals}"
  puts "Instance variables: {e.subject_instance_variables}"
  puts "Class variables: {e.subject_class_variables}"
  puts "Summary: {e.summary.inspect}"
end

This code...

Continue reading →


Redis cluster. Quick overview

Today I’ve tested version 3.0.0 of Redis server with includes Redis cluster. Here are some first thoughts about this.

Setup

Here are my servers:

 212.71.252.54  / 192.168.171.141 / node1
 176.58.103.254 / 192.168.171.142 / node2
 178.79.153.89  / 192.168.173.227 / node3

Local hosts (on each server):

 local hosts
192.168.171.141 node1
192.168.171.142 node2
192.168.173.227 node3

And remote (on my PC):

 remote hosts
212.71.252.54  node1
176.58.103.254 node2
178.79.153.89  node3

First of all, let’s download and extract it (on each node).

mkdir build && cd build
wget http://download.redis.io/releases/redis-3.0.0.tar.gz
tar -xvzf redis-3.0.0.tar.gz
cd redis-3.0.0/

Now we can build it

apt-get install -y make gcc build-essential
make MALLOC=libc  also jemalloc can be used

Now let’s run tests

apt-get install -y tk8.5 tcl8.5
make test
 a lot of output, should be green

Then we...

Continue reading →