rochefort 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rochefort.rb +41 -0
  3. metadata +72 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6db111e478f40ad5699e3f114cd62b9e0c210e8
4
+ data.tar.gz: 11a87da04f330d1c5ef75b34021dab4a86988bd5
5
+ SHA512:
6
+ metadata.gz: 2b49bb47b001270000b1b2629a5a54b4e626a5115db0fcf598297724ec81166be378fd700c3eb7c24bb0651d5cfea242d9b12665d28eb390082dee8504e233b6
7
+ data.tar.gz: cc9996aef5eaa453cfdea6691e361990ce83e4cd710f877d955da6644261d765c95bdf7b3d765f03e93aec8177a062b46443f534c714f90130ce60bd25f2cd53
data/lib/rochefort.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'rest-client'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ # example usage
6
+ # r = new Rochefort("http://localhost:8001")
7
+ # offset = r.append("example-namespace", "example-id","example-data")
8
+ # p r.get("example-namespace",offset)
9
+
10
+
11
+
12
+ class Rochefort
13
+ def initialize(url)
14
+ @urlSet = URI::join(url,'append').to_s
15
+ @urlGet = URI::join(url,'get').to_s
16
+ @urlGetMulti = URI::join(url,'getMulti').to_s
17
+ end
18
+
19
+ def append(opts)
20
+ data = RestClient::Request.execute(method: :post, url: "#{@urlSet}?storagePrefix=#{opts[:storage_prefix]}&id=#{opts[:id]}",payload: opts[:data], read_timeout: opts[:read_timeout] || 1, open_timeout: opts[:open_timeout] || 1)
21
+ out = JSON.parse(data.body)
22
+ return out["offset"]
23
+ end
24
+
25
+ def get(opts)
26
+ data = RestClient::Request.execute(method: :get, url: "#{@urlGet}?storagePrefix=#{opts[:storage_prefix]}&offset=#{opts[:offset]}", read_timeout: opts[:read_timeout] || 1, open_timeout: opts[:open_timeout] || 1)
27
+ return data
28
+ end
29
+
30
+ def getMulti(opts)
31
+ data = RestClient::Request.execute(method: :get, url: "#{@urlGetMulti}?storagePrefix=#{opts[:storage_prefix]}", payload: opts[:offsets].pack("q<*"), read_timeout: opts[:read_timeout] || 1, open_timeout: opts[:open_timeout] || 1).body
32
+ offset = 0
33
+ out = []
34
+ while offset != data.length
35
+ len = data.unpack('l<')[0]
36
+ out << data.slice(offset + 4, len)
37
+ offset += 4 + len
38
+ end
39
+ return out
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rochefort
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Borislav Nikolov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: curb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: rochefort is fast data append service that returns offsets to be indexed
42
+ email: jack@sofialondonmoskva.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/rochefort.rb
48
+ homepage: https://github.com/jackdoe/rochefort
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.0.14.1
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: client for rochefort storage service
72
+ test_files: []