ilios 0.4.9 → 0.4.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe04ef9746b0a963eade104e22e4285eac2a5192fbb19407c6d5373d0b69e9e0
4
- data.tar.gz: 66b83da5d0da081c2f737e7ce03ea4c878f62e28dfc6fc8816bece5d10ef941e
3
+ metadata.gz: 0def2f85dbab76062cb552bdf5263988913ea5e7bd7ecafd2681e81d91dcf5f6
4
+ data.tar.gz: 9c6b8696ae30614e09709ab2ba7706964c11b382d4b09361e9518d7a25d4891d
5
5
  SHA512:
6
- metadata.gz: ac26a4ed1f5f37807161acde7fbb62f2268f0e81b9d81b3412eb151650ad830cf38fbdb3283b67251c8aba526d56781b4ee4419e5ebb98a7459e6cfab5f39606
7
- data.tar.gz: 93a3620eea6b6af5982d0805d36350100d93340353e0ea0681bdfb4043dbfa59cdf8e4267c12989ef9620f9da99fca73b1a8d21fc412609054220bf696cdb4f0
6
+ metadata.gz: 68e58cdf0fb8c656428438f7b772cd9bced047f17aa711b593db533ea6a13393d831b1370b63bec6a7b5801f90ada694f10a553d3744cc05dbb9dd1695c46913
7
+ data.tar.gz: 5c483e7ef9ec943f7782fe20b8aa452255a21f18bd925fdcf5be9b8c1605443bf408351dac220376bfc2aa44d43fa377abcca2c173d72a77272bc30de30bf145
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gemspec
8
8
  gem 'minitest', '~> 5.20'
9
9
  gem 'rake', '~> 13.0'
10
10
  gem 'rake-compiler', '~> 1.2'
11
+ gem 'rbs', '~> 3.4'
11
12
  gem 'rubocop', '~> 1.57'
12
13
  gem 'rubocop-minitest', '~> 0.33.0'
13
14
  gem 'rubocop-performance', '~> 1.19'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Watson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Ilios
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/ilios.svg)](https://badge.fury.io/rb/ilios)
4
+ [![CI](https://github.com/Watson1978/ilios/actions/workflows/CI.yml/badge.svg)](https://github.com/Watson1978/ilios/actions/workflows/CI.yml)
5
+
3
6
  Ilios that Cassandra driver written by C language for Ruby using [DataStax C/C++ Driver](https://github.com/datastax/cpp-driver).
4
7
 
5
8
  ## Installation
data/Rakefile CHANGED
@@ -14,3 +14,13 @@ end
14
14
  Rake::TestTask.new do |task|
15
15
  task.pattern = 'test/test_*.rb'
16
16
  end
17
+
18
+ namespace :rbs do
19
+ desc 'Validate RBS definitions'
20
+ task :validate do
21
+ all_sigs = Dir.glob('sig').map { |dir| "-I #{dir}" }.join(' ')
22
+ sh("bundle exec rbs #{all_sigs} validate") do |ok, _|
23
+ abort('one or more rbs validate failed') unless ok
24
+ end
25
+ end
26
+ end
data/ext/ilios/cluster.c CHANGED
@@ -49,6 +49,7 @@ static VALUE cluster_connect(VALUE self)
49
49
  {
50
50
  CassandraSession *cassandra_session;
51
51
  CassandraCluster *cassandra_cluster;
52
+ CassFuture* connect_future;
52
53
  VALUE cassandra_session_obj;
53
54
  const char *keyspace = "";
54
55
 
@@ -60,16 +61,18 @@ static VALUE cluster_connect(VALUE self)
60
61
  cassandra_session_obj = CREATE_SESSION(cassandra_session);
61
62
  cassandra_session->cluster_obj = self;
62
63
  cassandra_session->session = cass_session_new();
63
- cassandra_session->connect_future = cass_session_connect_keyspace(cassandra_session->session, cassandra_cluster->cluster, keyspace);
64
- nogvl_future_wait(cassandra_session->connect_future);
64
+ connect_future = cass_session_connect_keyspace(cassandra_session->session, cassandra_cluster->cluster, keyspace);
65
+ nogvl_future_wait(connect_future);
65
66
 
66
- if (cass_future_error_code(cassandra_session->connect_future) != CASS_OK) {
67
+ if (cass_future_error_code(connect_future) != CASS_OK) {
67
68
  char error[4096] = { 0 };
68
69
 
69
- strncpy(error, cass_error_desc(cass_future_error_code(cassandra_session->connect_future)), sizeof(error) - 1);
70
+ strncpy(error, cass_error_desc(cass_future_error_code(connect_future)), sizeof(error) - 1);
71
+ cass_future_free(connect_future);
70
72
  rb_raise(eConnectError, "Unable to connect: %s", error);
71
73
  return Qnil;
72
74
  }
75
+ cass_future_free(connect_future);
73
76
 
74
77
  return cassandra_session_obj;
75
78
  }
data/ext/ilios/extconf.rb CHANGED
@@ -4,7 +4,6 @@ require File.expand_path('../../lib/ilios/version', __dir__)
4
4
  require 'fileutils'
5
5
  require 'mini_portile2'
6
6
  require 'mkmf'
7
- require 'native-package-installer'
8
7
 
9
8
  have_func('malloc_usable_size')
10
9
  have_func('malloc_size')
@@ -24,6 +23,7 @@ def num_cpu_cores
24
23
  end
25
24
 
26
25
  return 1 if cores <= 0
26
+
27
27
  cores >= 7 ? MAX_CORES : cores
28
28
  end
29
29
 
@@ -40,25 +40,9 @@ module LibuvInstaller
40
40
  end
41
41
 
42
42
  def self.install
43
- return if install_from_package
44
-
45
43
  install_from_source
46
44
  end
47
45
 
48
- def self.install_from_package
49
- NativePackageInstaller.install(
50
- alpine_linux: 'libuv-dev',
51
- alt_linux: 'libuv',
52
- arch_linux: 'libuv',
53
- debian: 'libuv1-dev',
54
- freebsd: 'libuv',
55
- gentoo_linux: 'libuv',
56
- homebrew: 'libuv',
57
- macports: 'libuv',
58
- redhat: 'libuv-devel'
59
- )
60
- end
61
-
62
46
  def self.install_from_source
63
47
  unless File.exist?(LIBUV_INSTALL_PATH)
64
48
  libuv_recipe = LibuvRecipe.new('libuv', Ilios::LIBUV_VERSION, make_command: "make -j #{num_cpu_cores}")
@@ -158,4 +142,7 @@ else
158
142
  CassandraDriverInstaller.install
159
143
  end
160
144
 
145
+ $CPPFLAGS += " #{ENV['CPPFLAGS']}"
146
+ $LDFLAGS += " #{ENV['LDFLAGS']}"
147
+
161
148
  create_makefile('ilios')
data/ext/ilios/future.c CHANGED
@@ -1,6 +1,7 @@
1
1
  #include "ilios.h"
2
2
 
3
3
  #define THREAD_MAX 5
4
+ #define QUEUE_MAX 100
4
5
 
5
6
  typedef struct
6
7
  {
@@ -31,7 +32,7 @@ const rb_data_type_t cassandra_future_data_type = {
31
32
 
32
33
  static void future_thread_pool_init(future_thread_pool *pool)
33
34
  {
34
- pool->queue = rb_funcall(cQueue, id_new, 0);
35
+ pool->queue = rb_funcall(cSizedQueue, id_new, 1, INT2NUM(QUEUE_MAX));
35
36
  rb_gc_register_mark_object(pool->queue);
36
37
  }
37
38
 
data/ext/ilios/ilios.c CHANGED
@@ -11,7 +11,7 @@ VALUE eConnectError;
11
11
  VALUE eExecutionError;
12
12
  VALUE eStatementError;
13
13
 
14
- VALUE cQueue;
14
+ VALUE cSizedQueue;
15
15
 
16
16
  VALUE id_to_time;
17
17
  VALUE id_new;
@@ -58,6 +58,18 @@ static void ilios_free(void *ptr)
58
58
  }
59
59
  }
60
60
 
61
+ /**
62
+ * Sets the log level.
63
+ * Default is +LOG_ERROR+.
64
+ *
65
+ * @return [Cassandra] self.
66
+ */
67
+ static VALUE cassandra_set_log_level(VALUE self, VALUE log_level)
68
+ {
69
+ cass_log_set_level(NUM2INT(log_level));
70
+ return self;
71
+ }
72
+
61
73
  void Init_ilios(void)
62
74
  {
63
75
  rb_ext_ractor_safe(true);
@@ -73,7 +85,7 @@ void Init_ilios(void)
73
85
  eExecutionError = rb_define_class_under(mCassandra, "ExecutionError", rb_eStandardError);
74
86
  eStatementError = rb_define_class_under(mCassandra, "StatementError", rb_eStandardError);
75
87
 
76
- cQueue = rb_const_get(rb_cThread, rb_intern("Queue"));
88
+ cSizedQueue = rb_const_get(rb_cThread, rb_intern("SizedQueue"));
77
89
 
78
90
  id_to_time = rb_intern("to_time");
79
91
  id_new = rb_intern("new");
@@ -83,6 +95,15 @@ void Init_ilios(void)
83
95
  id_report_on_exception = rb_intern("report_on_exception=");
84
96
  sym_unsupported_column_type = ID2SYM(rb_intern("unsupported_column_type"));
85
97
 
98
+ rb_define_module_function(mCassandra, "log_level", cassandra_set_log_level, 1);
99
+ rb_define_const(mCassandra, "LOG_DISABLED", INT2NUM(CASS_LOG_DISABLED));
100
+ rb_define_const(mCassandra, "LOG_CRITICAL", INT2NUM(CASS_LOG_CRITICAL));
101
+ rb_define_const(mCassandra, "LOG_ERROR", INT2NUM(CASS_LOG_ERROR));
102
+ rb_define_const(mCassandra, "LOG_WARN", INT2NUM(CASS_LOG_WARN));
103
+ rb_define_const(mCassandra, "LOG_INFO", INT2NUM(CASS_LOG_INFO));
104
+ rb_define_const(mCassandra, "LOG_DEBUG", INT2NUM(CASS_LOG_DEBUG));
105
+ rb_define_const(mCassandra, "LOG_TRACE", INT2NUM(CASS_LOG_TRACE));
106
+
86
107
  Init_cluster();
87
108
  Init_session();
88
109
  Init_statement();
data/ext/ilios/ilios.h CHANGED
@@ -35,7 +35,6 @@ typedef struct
35
35
  typedef struct
36
36
  {
37
37
  CassSession* session;
38
- CassFuture* connect_future;
39
38
  VALUE cluster_obj;
40
39
  } CassandraSession;
41
40
 
@@ -85,7 +84,7 @@ extern VALUE eConnectError;
85
84
  extern VALUE eExecutionError;
86
85
  extern VALUE eStatementError;
87
86
 
88
- extern VALUE cQueue;
87
+ extern VALUE cSizedQueue;
89
88
 
90
89
  extern VALUE id_to_time;
91
90
  extern VALUE id_new;
data/ext/ilios/session.c CHANGED
@@ -136,9 +136,6 @@ static void session_destroy(void *ptr)
136
136
  if (cassandra_session->session) {
137
137
  cass_session_free(cassandra_session->session);
138
138
  }
139
- if (cassandra_session->connect_future) {
140
- cass_future_free(cassandra_session->connect_future);
141
- }
142
139
  xfree(cassandra_session);
143
140
  }
144
141
 
data/ilios.gemspec CHANGED
@@ -35,5 +35,4 @@ Gem::Specification.new do |spec|
35
35
  spec.extensions << 'ext/ilios/extconf.rb'
36
36
 
37
37
  spec.add_runtime_dependency('mini_portile2', '~> 2.8')
38
- spec.add_runtime_dependency('native-package-installer', '~> 1.1', '>= 1.1.9')
39
38
  end
data/lib/ilios/version.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ilios
4
- VERSION = '0.4.9'
4
+ VERSION = '0.4.11'
5
5
  public_constant :VERSION
6
6
 
7
7
  CASSANDRA_CPP_DRIVER_VERSION = '2.17.1'
8
8
  public_constant :CASSANDRA_CPP_DRIVER_VERSION
9
9
 
10
- LIBUV_VERSION = '1.47.0'
10
+ LIBUV_VERSION = '1.48.0'
11
11
  public_constant :LIBUV_VERSION
12
12
  end
data/sig/ilios.rbs CHANGED
@@ -2,7 +2,25 @@ module Ilios
2
2
  VERSION: String
3
3
 
4
4
  module Cassandra
5
+ LOG_DISABLED: Integer
6
+ LOG_CRITICAL: Integer
7
+ LOG_ERROR: Integer
8
+ LOG_WARN: Integer
9
+ LOG_INFO: Integer
10
+ LOG_DEBUG: Integer
11
+ LOG_TRACE: Integer
12
+
13
+ def self.log_level: (Integer log_level) -> self
14
+
5
15
  class Cluster
16
+ PROTOCOL_VERSION_V1: Integer
17
+ PROTOCOL_VERSION_V2: Integer
18
+ PROTOCOL_VERSION_V3: Integer
19
+ PROTOCOL_VERSION_V4: Integer
20
+ PROTOCOL_VERSION_V5: Integer
21
+ PROTOCOL_VERSION_DSEV1: Integer
22
+ PROTOCOL_VERSION_DSEV2: Integer
23
+
6
24
  def connect: () -> Ilios::Cassandra::Session
7
25
  def hosts: (Array[String]) -> self
8
26
  def port: (Integer) -> self
@@ -23,7 +41,7 @@ module Ilios
23
41
  end
24
42
 
25
43
  class Statement
26
- def bind: (Hash[Symbol, untyped] | Hash[String, untyped]) -> self
44
+ def bind: (Hash[Symbol | String, untyped]) -> self
27
45
  def page_size=: (Integer) -> self
28
46
  def idempotent=: (true | false) -> self
29
47
  end
@@ -31,7 +49,7 @@ module Ilios
31
49
  class Future
32
50
  def on_success: () { (Ilios::Cassandra::Result) -> void } -> self
33
51
  def on_failure: () { () -> void } -> self
34
- def await: () -> Ilios::Cassandra::Future
52
+ def await: () -> self
35
53
  end
36
54
 
37
55
  class Result
@@ -39,10 +57,9 @@ module Ilios
39
57
 
40
58
  include Enumerable[row_type]
41
59
 
42
- def each: () { (row_type) -> void } -> void |
43
- () -> ::Enumerator[row_type, self]
44
- def next_page: () -> Ilios::Cassandra::Result |
45
- () -> nil
60
+ def each: () { (row_type) -> void } -> void
61
+ | () -> ::Enumerator[row_type, self]
62
+ def next_page: () -> (Ilios::Cassandra::Result | nil)
46
63
  end
47
64
  end
48
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ilios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-10 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_portile2
@@ -24,26 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.8'
27
- - !ruby/object:Gem::Dependency
28
- name: native-package-installer
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 1.1.9
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '1.1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 1.1.9
47
27
  description: Cassandra driver written by C language
48
28
  email:
49
29
  - watson1978@gmail.com
@@ -54,6 +34,7 @@ extra_rdoc_files: []
54
34
  files:
55
35
  - ".yardopts"
56
36
  - Gemfile
37
+ - LICENSE
57
38
  - README.md
58
39
  - Rakefile
59
40
  - docker-compose.yml
@@ -77,7 +58,7 @@ metadata:
77
58
  homepage_uri: https://github.com/Watson1978/ilios
78
59
  source_code_uri: https://github.com/Watson1978/ilios
79
60
  bug_tracker_uri: https://github.com/Watson1978/ilios/issues
80
- documentation_uri: https://www.rubydoc.info/gems/ilios/0.4.9
61
+ documentation_uri: https://www.rubydoc.info/gems/ilios/0.4.11
81
62
  rubygems_mfa_required: 'true'
82
63
  post_install_message:
83
64
  rdoc_options: []