ruby_volt 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE +20 -0
- data/README.md +282 -0
- data/lib/ruby_volt.rb +33 -0
- data/lib/ruby_volt/base.rb +105 -0
- data/lib/ruby_volt/connection.rb +150 -0
- data/lib/ruby_volt/data_type.rb +50 -0
- data/lib/ruby_volt/data_type/app_data_type.rb +24 -0
- data/lib/ruby_volt/data_type/app_data_type/procedure_call_status_code.rb +14 -0
- data/lib/ruby_volt/data_type/app_data_type/wire_type_info.rb +22 -0
- data/lib/ruby_volt/data_type/basic.rb +36 -0
- data/lib/ruby_volt/data_type/basic/fixed_size.rb +26 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/decimal.rb +45 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/float.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/geography_point.rb +28 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type.rb +20 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/byte.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/integer.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/long.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/short.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_byte.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_integer.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_long.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_short.rb +9 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/null.rb +13 -0
- data/lib/ruby_volt/data_type/basic/fixed_size/timestamp.rb +24 -0
- data/lib/ruby_volt/data_type/basic/geography.rb +61 -0
- data/lib/ruby_volt/data_type/basic/string.rb +19 -0
- data/lib/ruby_volt/data_type/basic/varbinary.rb +34 -0
- data/lib/ruby_volt/data_type/complex.rb +11 -0
- data/lib/ruby_volt/data_type/complex/parameter.rb +20 -0
- data/lib/ruby_volt/data_type/complex/parameter_set.rb +19 -0
- data/lib/ruby_volt/data_type/complex/serializable_exception.rb +43 -0
- data/lib/ruby_volt/data_type/complex/volt_table.rb +96 -0
- data/lib/ruby_volt/data_type/compound.rb +8 -0
- data/lib/ruby_volt/data_type/compound/array.rb +42 -0
- data/lib/ruby_volt/data_type/extensions.rb +20 -0
- data/lib/ruby_volt/exceptions.rb +67 -0
- data/lib/ruby_volt/helper.rb +29 -0
- data/lib/ruby_volt/message.rb +29 -0
- data/lib/ruby_volt/message/invocation_request.rb +18 -0
- data/lib/ruby_volt/message/login_message.rb +17 -0
- data/lib/ruby_volt/meta.rb +6 -0
- data/lib/ruby_volt/meta/geography.rb +165 -0
- data/lib/ruby_volt/read_partial.rb +23 -0
- data/lib/ruby_volt/response.rb +24 -0
- data/lib/ruby_volt/response/invocation_response.rb +64 -0
- data/lib/ruby_volt/response/login_response.rb +27 -0
- data/lib/ruby_volt/version.rb +3 -0
- data/lib/ruby_volt/volt_table.rb +37 -0
- metadata +108 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module RubyVolt
|
2
|
+
class LoginResponse < Response
|
3
|
+
|
4
|
+
# A response is generated to a login request and success is indicated with a result code of 0. Any other value indicates authentication failure and will be followed by the server closing the connection. A response code of 1 indicates that the there are too many connections. A response code of 2 indicates that authentication failed because the client took too long to transmit credentials. A response code of 3 indicates a corrupt or invalid login message. If the response code is 0 the response will also contain additional information following the result code. A 4 byte integer specifying the host id of the Volt node . An 8 byte long specifying a connection id that is unique among connections to that node. An 8 byte long timestamp (milliseconds since Unix epoch) and a 4 byte IPV4 address representing the time the cluster was started and the address of the leader node. These two values uniquely identify a Volt cluster instance. And finally a string containing a textual description of the build the node being connected to is running.
|
5
|
+
|
6
|
+
def unpack!(&block)
|
7
|
+
wrap do
|
8
|
+
data[:auth_result] = DataType::Byte.unpack(bytes) # Authentication result code
|
9
|
+
|
10
|
+
case data[:auth_result]
|
11
|
+
when -1 then raise(AuthenticationRejected, "Authentication rejected! wrong username or password")
|
12
|
+
when 1 then raise(TooManyConnections, "Too many connections")
|
13
|
+
when 2 then raise(TooLongToTransmitCredentials, "Too long to transmit credentials")
|
14
|
+
when 3 then raise(InvalidLoginMessage, "Corrupt or invalid login message")
|
15
|
+
when 0 then
|
16
|
+
data[:server_host_id] = DataType::Integer.unpack(bytes) # Server Host ID
|
17
|
+
data[:connection_id] = DataType::Long.unpack(bytes) # Connection ID
|
18
|
+
data[:cluster_start_ms] = DataType::Long.unpack(bytes) # Cluster start timestamp (milliseconds since Unix epoch)
|
19
|
+
data[:leader_ipv4] = DataType::UInteger.unpack(bytes) # Leader IPV4 address
|
20
|
+
data[:leader_ipv4] = IPAddr.new(data[:leader_ipv4], ::Socket::AF_INET) if data[:leader_ipv4]
|
21
|
+
data[:build_str] = DataType::String.unpack(bytes) # Build string (variable)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RubyVolt
|
2
|
+
class VoltTable
|
3
|
+
attr_reader :index, :total_table_length, :total_metadata_length, :status_code, :columns, :rows
|
4
|
+
|
5
|
+
def initialize(index, total_table_length, total_metadata_length, status_code, columns, rows = [])
|
6
|
+
@index = index
|
7
|
+
@total_table_length = total_table_length
|
8
|
+
@total_metadata_length = total_metadata_length
|
9
|
+
@status_code = status_code
|
10
|
+
@columns = columns
|
11
|
+
@row = ::Struct.new(*columns.map {|c| c[0].to_sym})
|
12
|
+
@rows = []
|
13
|
+
rows.each {|r| add_struct(r)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def inspect
|
17
|
+
"#<#{self.class.name} index=#{@index} total_table_length=#{@total_table_length} total_metadata_length=#{@total_metadata_length} rows=#{@rows.size}>"
|
18
|
+
end
|
19
|
+
|
20
|
+
def column_names
|
21
|
+
columns.map(&:last)
|
22
|
+
end
|
23
|
+
|
24
|
+
def struct(*row)
|
25
|
+
@row.new(*row)
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_struct(row)
|
29
|
+
@rows << struct(*row)
|
30
|
+
end
|
31
|
+
|
32
|
+
def method_missing(m, *args, &block)
|
33
|
+
rows.send(m, *args, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_volt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Valery Kvon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.11'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.11'
|
27
|
+
description: Pure Ruby client for VoltDB - one of the fastest in-memory databases
|
28
|
+
on the planet. Threadsafe and fast enough wire client implementation, based on protocol
|
29
|
+
specifications Version 1 (01/26/2016).
|
30
|
+
email: addagger@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- CHANGELOG.md
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- lib/ruby_volt.rb
|
39
|
+
- lib/ruby_volt/base.rb
|
40
|
+
- lib/ruby_volt/connection.rb
|
41
|
+
- lib/ruby_volt/data_type.rb
|
42
|
+
- lib/ruby_volt/data_type/app_data_type.rb
|
43
|
+
- lib/ruby_volt/data_type/app_data_type/procedure_call_status_code.rb
|
44
|
+
- lib/ruby_volt/data_type/app_data_type/wire_type_info.rb
|
45
|
+
- lib/ruby_volt/data_type/basic.rb
|
46
|
+
- lib/ruby_volt/data_type/basic/fixed_size.rb
|
47
|
+
- lib/ruby_volt/data_type/basic/fixed_size/decimal.rb
|
48
|
+
- lib/ruby_volt/data_type/basic/fixed_size/float.rb
|
49
|
+
- lib/ruby_volt/data_type/basic/fixed_size/geography_point.rb
|
50
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type.rb
|
51
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/byte.rb
|
52
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/integer.rb
|
53
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/long.rb
|
54
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/short.rb
|
55
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_byte.rb
|
56
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_integer.rb
|
57
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_long.rb
|
58
|
+
- lib/ruby_volt/data_type/basic/fixed_size/integer_type/u_short.rb
|
59
|
+
- lib/ruby_volt/data_type/basic/fixed_size/null.rb
|
60
|
+
- lib/ruby_volt/data_type/basic/fixed_size/timestamp.rb
|
61
|
+
- lib/ruby_volt/data_type/basic/geography.rb
|
62
|
+
- lib/ruby_volt/data_type/basic/string.rb
|
63
|
+
- lib/ruby_volt/data_type/basic/varbinary.rb
|
64
|
+
- lib/ruby_volt/data_type/complex.rb
|
65
|
+
- lib/ruby_volt/data_type/complex/parameter.rb
|
66
|
+
- lib/ruby_volt/data_type/complex/parameter_set.rb
|
67
|
+
- lib/ruby_volt/data_type/complex/serializable_exception.rb
|
68
|
+
- lib/ruby_volt/data_type/complex/volt_table.rb
|
69
|
+
- lib/ruby_volt/data_type/compound.rb
|
70
|
+
- lib/ruby_volt/data_type/compound/array.rb
|
71
|
+
- lib/ruby_volt/data_type/extensions.rb
|
72
|
+
- lib/ruby_volt/exceptions.rb
|
73
|
+
- lib/ruby_volt/helper.rb
|
74
|
+
- lib/ruby_volt/message.rb
|
75
|
+
- lib/ruby_volt/message/invocation_request.rb
|
76
|
+
- lib/ruby_volt/message/login_message.rb
|
77
|
+
- lib/ruby_volt/meta.rb
|
78
|
+
- lib/ruby_volt/meta/geography.rb
|
79
|
+
- lib/ruby_volt/read_partial.rb
|
80
|
+
- lib/ruby_volt/response.rb
|
81
|
+
- lib/ruby_volt/response/invocation_response.rb
|
82
|
+
- lib/ruby_volt/response/login_response.rb
|
83
|
+
- lib/ruby_volt/version.rb
|
84
|
+
- lib/ruby_volt/volt_table.rb
|
85
|
+
homepage: https://github.com/addagger/ruby_volt
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.5.0
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.3.6
|
103
|
+
requirements: []
|
104
|
+
rubygems_version: 3.0.3
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: VoltDB Wire Protocol Client for Ruby programming language
|
108
|
+
test_files: []
|