Class: Mysql2Replication::Client
- Inherits:
-
Object
- Object
- Mysql2Replication::Client
- Includes:
- Enumerable
- Defined in:
- ext/mysql2-replication/mysql2_replication.c
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
- #fetch ⇒ Object
- #file_name ⇒ Object
- #file_name=(file_name) ⇒ Object
- #flags ⇒ Object
- #flags=(flags) ⇒ Object
- #initialize(*args) ⇒ Object constructor
- #open ⇒ Object
- #server_id ⇒ Object
- #server_id=(server_id) ⇒ Object
- #start_position ⇒ Object
- #start_position=(start_position) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 833 static VALUE rbm2_replication_client_initialize(int argc, VALUE *argv, VALUE self) { VALUE rb_client; VALUE ; VALUE rb_checksum = RUBY_Qnil; rb_scan_args(argc, argv, "10:", &rb_client, &); if (!RB_NIL_P()) { static ID keyword_ids[1]; VALUE keyword_args[1]; if (keyword_ids[0] == 0) { CONST_ID(keyword_ids[0], "checksum"); } rb_get_kwargs(, keyword_ids, 0, 1, keyword_args); if (keyword_args[0] != RUBY_Qundef) { rb_checksum = keyword_args[0]; } } rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); wrapper->rb_client = rb_client; wrapper->rpl = mariadb_rpl_init(rbm2_replication_client_wrapper_get_client(wrapper)); if (!wrapper->rpl) { rbm2_replication_client_raise(self); } { VALUE rb_query; if (RB_NIL_P(rb_checksum)) { rb_query = rb_str_new_cstr("SET @master_binlog_checksum = " "@@global.binlog_checksum"); } else { rb_query = rb_sprintf("SET @master_binlog_checksum = '%"PRIsVALUE"'", rb_checksum); } ID id_query; CONST_ID(id_query, "query"); rb_funcall(rb_client, id_query, 1, rb_query); } if (rb_equal(rb_str_new_cstr("NONE"), rb_checksum)) { wrapper->force_disable_use_checksum = true; } else { wrapper->force_disable_use_checksum = false; } return RUBY_Qnil; } |
Instance Method Details
#close ⇒ Object
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 1026 static VALUE rbm2_replication_client_close(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); rb_thread_call_without_gvl(rbm2_replication_client_close_without_gvl, wrapper, RUBY_UBF_IO, 0); return Qnil; } |
#each ⇒ Object
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 1283 static VALUE rbm2_replication_client_each(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); MYSQL *client = rbm2_replication_client_wrapper_get_client(wrapper); do { MARIADB_RPL_EVENT *event = rb_thread_call_without_gvl(rbm2_replication_client_fetch_without_gvl, wrapper, RUBY_UBF_IO, 0); if (mysql_errno(client) != 0) { rbm2_replication_client_raise(self); } if (!event) { if (wrapper->rpl->buffer_size == 0) { return RUBY_Qnil; } continue; } rb_yield(rbm2_replication_event_new(wrapper, event)); } while (true); return RUBY_Qnil; } |
#fetch ⇒ Object
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 1258 static VALUE rbm2_replication_client_fetch(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); MYSQL *client = rbm2_replication_client_wrapper_get_client(wrapper); do { MARIADB_RPL_EVENT *event = rb_thread_call_without_gvl(rbm2_replication_client_fetch_without_gvl, wrapper, RUBY_UBF_IO, 0); if (mysql_errno(client) != 0) { rbm2_replication_client_raise(self); } if (!event) { if (wrapper->rpl->buffer_size == 0) { return RUBY_Qnil; } continue; } return rbm2_replication_event_new(wrapper, event); } while (true); } |
#file_name ⇒ Object
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 884 static VALUE rbm2_replication_client_get_file_name(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); const char *file_name; size_t file_name_length; int result = (wrapper->rpl, MARIADB_RPL_FILENAME, &file_name, &file_name_length); if (result != 0) { rbm2_replication_client_raise(self); } return rb_str_new(file_name, file_name_length); } |
#file_name=(file_name) ⇒ Object
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 901 static VALUE rbm2_replication_client_set_file_name(VALUE self, VALUE file_name) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); int result; if (RB_NIL_P(file_name)) { result = (wrapper->rpl, MARIADB_RPL_FILENAME, NULL, 0); } else { result = (wrapper->rpl, MARIADB_RPL_FILENAME, RSTRING_PTR(file_name), RSTRING_LEN(file_name)); } if (result != 0) { rbm2_replication_client_raise(self); } return file_name; } |
#flags ⇒ Object
982 983 984 985 986 987 988 989 990 991 992 993 994 995 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 982 static VALUE rbm2_replication_client_get_flags(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); unsigned int flags; int result = (wrapper->rpl, MARIADB_RPL_FLAGS, &flags); if (result != 0) { rbm2_replication_client_raise(self); } return UINT2NUM(flags); } |
#flags=(flags) ⇒ Object
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 997 static VALUE rbm2_replication_client_set_flags(VALUE self, VALUE flags) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); int result = (wrapper->rpl, MARIADB_RPL_FLAGS, NUM2UINT(flags)); if (result != 0) { rbm2_replication_client_raise(self); } return flags; } |
#open ⇒ Object
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 1046 static VALUE rbm2_replication_client_open(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); int result = (intptr_t)rb_thread_call_without_gvl( rbm2_replication_client_open_without_gvl, wrapper, RUBY_UBF_IO, 0); if (result != 0) { rbm2_replication_client_raise(self); } if (rb_block_given_p()) { return rb_ensure(rb_yield, self, rbm2_replication_client_close, self); } else { return Qnil; } } |
#server_id ⇒ Object
953 954 955 956 957 958 959 960 961 962 963 964 965 966 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 953 static VALUE rbm2_replication_client_get_server_id(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); unsigned int server_id; int result = (wrapper->rpl, MARIADB_RPL_SERVER_ID, &server_id); if (result != 0) { rbm2_replication_client_raise(self); } return UINT2NUM(server_id); } |
#server_id=(server_id) ⇒ Object
968 969 970 971 972 973 974 975 976 977 978 979 980 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 968 static VALUE rbm2_replication_client_set_server_id(VALUE self, VALUE server_id) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); int result = (wrapper->rpl, MARIADB_RPL_SERVER_ID, NUM2UINT(server_id)); if (result != 0) { rbm2_replication_client_raise(self); } return server_id; } |
#start_position ⇒ Object
924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 924 static VALUE rbm2_replication_client_get_start_position(VALUE self) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); unsigned long start_position; int result = (wrapper->rpl, MARIADB_RPL_START, &start_position); if (result != 0) { rbm2_replication_client_raise(self); } return ULONG2NUM(start_position); } |
#start_position=(start_position) ⇒ Object
939 940 941 942 943 944 945 946 947 948 949 950 951 |
# File 'ext/mysql2-replication/mysql2_replication.c', line 939 static VALUE rbm2_replication_client_set_start_position(VALUE self, VALUE start_position) { rbm2_replication_client_wrapper *wrapper = rbm2_replication_client_get_wrapper(self); int result = (wrapper->rpl, MARIADB_RPL_START, NUM2ULONG(start_position)); if (result != 0) { rbm2_replication_client_raise(self); } return start_position; } |