{"action":"created","comment":{"url":"https://api.github.com/repos/arthurnn/memcached/pulls/comments/56347099","id":56347099,"diff_hunk":"@@ -95,60 +95,36 @@ rb_memcached_error_check(memcached_return_t rc)\n \t\tcase MEMCACHED_SUCCESS: return Qtrue; \\\n \t\tdefault: return Qfalse; }}\n \n-\n static VALUE\n-rb_memcached_alloc(VALUE klass)\n+rb_connection_check_cfg(VALUE klass, VALUE rb_config)\n {\n-\tmemcached_st *mc = memcached_create(NULL);\n-\treturn Data_Wrap_Struct(klass, NULL, memcached_free, mc);\n+\tchar error_buffer[512];\n+\tmemcached_return_t rc;\n+\n+\tCheck_Type(rb_config, T_STRING);\n+\n+\trc = libmemcached_check_configuration(\n+\t\tRSTRING_PTR(rb_config), RSTRING_LEN(rb_config),\n+\t\terror_buffer, sizeof(error_buffer));\n+\n+\tif (rc != MEMCACHED_SUCCESS)\n+\t\trb_raise(rb_eArgError, \"failed to parse config string\\nconfig: '%s'\\nmessage: %s\",\n+\t\t\t\tStringValueCStr(rb_config), error_buffer);\n+\n+\treturn Qnil;\n }\n \n static VALUE\n-rb_connection_new(VALUE klass, VALUE rb_servers)\n+rb_connection_new(VALUE klass, VALUE rb_config)\n {\n-\tVALUE rb_mc = rb_memcached_alloc(klass);\n-\n \tmemcached_st *mc;\n-\tmemcached_return_t rc;\n-\tlong i;\n-\n-\tUnwrapMemcached(rb_mc, mc);\n-\tCheck_Type(rb_servers, T_ARRAY);\n-\n-\tfor (i = 0; i < RARRAY_LEN(rb_servers); ++i) {\n-\t\tVALUE rb_server, rb_backend;\n-\n-\t\trb_server = rb_ary_entry(rb_servers, i);\n-\t\tCheck_Type(rb_server, T_ARRAY);\n-\n-\t\trb_backend = rb_ary_entry(rb_server, 0);\n-\t\tCheck_Type(rb_backend, T_SYMBOL);\n-\n-\t\tif (SYM2ID(rb_backend) == id_tcp) {\n-\t\t\tVALUE rb_hostname = rb_ary_entry(rb_server, 1);\n-\t\t\tVALUE rb_port = rb_ary_entry(rb_server, 2);\n-\n-\t\t\tCheck_Type(rb_hostname, T_STRING);\n-\t\t\tCheck_Type(rb_port, T_FIXNUM);\n-\n-\t\t\t// TODO: add weight\n-\t\t\t//VALUE rb_weight = rb_ary_entry(rb_server, 3);\n-\t\t\trc = memcached_server_add(mc, StringValueCStr(rb_hostname), NUM2INT(rb_port));\n-\t\t\trb_memcached_error_check(rc);\n-\t\t}\n-\t\telse if (SYM2ID(rb_backend) == id_socket) {\n-\t\t\tVALUE rb_fd = rb_ary_entry(rb_server, 1);\n-\t\t\tCheck_Type(rb_fd, T_STRING);\n-\t\t\trc = memcached_server_add_unix_socket(mc, StringValueCStr(rb_fd));\n-\t\t\trb_memcached_error_check(rc);\n-\t\t}\n+\tCheck_Type(rb_config, T_STRING);\n+\tmc = memcached(RSTRING_PTR(rb_config), RSTRING_LEN(rb_config));\n+\tif (!mc) {\n+\t\trb_connection_check_cfg(rb_cConnection, rb_config);","path":"ext/memcached_rb/memcached_rb.c","position":76,"original_position":70,"commit_id":"7cc8a95610bd17a8a7be70994809fae699d49838","original_commit_id":"d2496275f5c67f4fa6ccfc8c407033713d001de2","user":{"login":"vmg","id":42793,"avatar_url":"https://avatars.githubusercontent.com/u/42793?v=3","gravatar_id":"","url":"https://api.github.com/users/vmg","html_url":"https://github.com/vmg","followers_url":"https://api.github.com/users/vmg/followers","following_url":"https://api.github.com/users/vmg/following{/other_user}","gists_url":"https://api.github.com/users/vmg/gists{/gist_id}","starred_url":"https://api.github.com/users/vmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmg/subscriptions","organizations_url":"https://api.github.com/users/vmg/orgs","repos_url":"https://api.github.com/users/vmg/repos","events_url":"https://api.github.com/users/vmg/events{/privacy}","received_events_url":"https://api.github.com/users/vmg/received_events","type":"User","site_admin":true},"body":"I decided to do it this way because the `Client` class checks the config eagerly and then calls `Connection#new`. Hence, if the config is broken it means that something went very poorly.","created_at":"2016-03-16T14:52:02Z","updated_at":"2016-03-16T14:52:02Z","html_url":"https://github.com/arthurnn/memcached/pull/165#discussion_r56347099","pull_request_url":"https://api.github.com/repos/arthurnn/memcached/pulls/165","_links":{"self":{"href":"https://api.github.com/repos/arthurnn/memcached/pulls/comments/56347099"},"html":{"href":"https://github.com/arthurnn/memcached/pull/165#discussion_r56347099"},"pull_request":{"href":"https://api.github.com/repos/arthurnn/memcached/pulls/165"}}},"pull_request":{"url":"https://api.github.com/repos/arthurnn/memcached/pulls/165","id":63045563,"html_url":"https://github.com/arthurnn/memcached/pull/165","diff_url":"https://github.com/arthurnn/memcached/pull/165.diff","patch_url":"https://github.com/arthurnn/memcached/pull/165.patch","issue_url":"https://api.github.com/repos/arthurnn/memcached/issues/165","number":165,"state":"open","locked":false,"title":"Cleanup part 2","user":{"login":"vmg","id":42793,"avatar_url":"https://avatars.githubusercontent.com/u/42793?v=3","gravatar_id":"","url":"https://api.github.com/users/vmg","html_url":"https://github.com/vmg","followers_url":"https://api.github.com/users/vmg/followers","following_url":"https://api.github.com/users/vmg/following{/other_user}","gists_url":"https://api.github.com/users/vmg/gists{/gist_id}","starred_url":"https://api.github.com/users/vmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmg/subscriptions","organizations_url":"https://api.github.com/users/vmg/orgs","repos_url":"https://api.github.com/users/vmg/repos","events_url":"https://api.github.com/users/vmg/events{/privacy}","received_events_url":"https://api.github.com/users/vmg/received_events","type":"User","site_admin":true},"body":"Hey @arthurnn!\r\n\r\nHere's another batch of commits. Since these are minor changes, I've split them in separate commits that should be straightforward to review. All my notes are written as commit messages this time.\r\n\r\ncc @arthurnn ","created_at":"2016-03-16T10:54:11Z","updated_at":"2016-03-16T14:52:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dde45d6a7107bd401c3925331fb32d8ae5964cc9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/arthurnn/memcached/pulls/165/commits","review_comments_url":"https://api.github.com/repos/arthurnn/memcached/pulls/165/comments","review_comment_url":"https://api.github.com/repos/arthurnn/memcached/pulls/comments{/number}","comments_url":"https://api.github.com/repos/arthurnn/memcached/issues/165/comments","statuses_url":"https://api.github.com/repos/arthurnn/memcached/statuses/7cc8a95610bd17a8a7be70994809fae699d49838","head":{"label":"arthurnn:vmg/cleanup2","ref":"vmg/cleanup2","sha":"7cc8a95610bd17a8a7be70994809fae699d49838","user":{"login":"arthurnn","id":833383,"avatar_url":"https://avatars.githubusercontent.com/u/833383?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurnn","html_url":"https://github.com/arthurnn","followers_url":"https://api.github.com/users/arthurnn/followers","following_url":"https://api.github.com/users/arthurnn/following{/other_user}","gists_url":"https://api.github.com/users/arthurnn/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurnn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurnn/subscriptions","organizations_url":"https://api.github.com/users/arthurnn/orgs","repos_url":"https://api.github.com/users/arthurnn/repos","events_url":"https://api.github.com/users/arthurnn/events{/privacy}","received_events_url":"https://api.github.com/users/arthurnn/received_events","type":"User","site_admin":true},"repo":{"id":24449,"name":"memcached","full_name":"arthurnn/memcached","owner":{"login":"arthurnn","id":833383,"avatar_url":"https://avatars.githubusercontent.com/u/833383?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurnn","html_url":"https://github.com/arthurnn","followers_url":"https://api.github.com/users/arthurnn/followers","following_url":"https://api.github.com/users/arthurnn/following{/other_user}","gists_url":"https://api.github.com/users/arthurnn/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurnn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurnn/subscriptions","organizations_url":"https://api.github.com/users/arthurnn/orgs","repos_url":"https://api.github.com/users/arthurnn/repos","events_url":"https://api.github.com/users/arthurnn/events{/privacy}","received_events_url":"https://api.github.com/users/arthurnn/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/arthurnn/memcached","description":"A Ruby interface to the libmemcached C client","fork":false,"url":"https://api.github.com/repos/arthurnn/memcached","forks_url":"https://api.github.com/repos/arthurnn/memcached/forks","keys_url":"https://api.github.com/repos/arthurnn/memcached/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arthurnn/memcached/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arthurnn/memcached/teams","hooks_url":"https://api.github.com/repos/arthurnn/memcached/hooks","issue_events_url":"https://api.github.com/repos/arthurnn/memcached/issues/events{/number}","events_url":"https://api.github.com/repos/arthurnn/memcached/events","assignees_url":"https://api.github.com/repos/arthurnn/memcached/assignees{/user}","branches_url":"https://api.github.com/repos/arthurnn/memcached/branches{/branch}","tags_url":"https://api.github.com/repos/arthurnn/memcached/tags","blobs_url":"https://api.github.com/repos/arthurnn/memcached/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arthurnn/memcached/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arthurnn/memcached/git/refs{/sha}","trees_url":"https://api.github.com/repos/arthurnn/memcached/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arthurnn/memcached/statuses/{sha}","languages_url":"https://api.github.com/repos/arthurnn/memcached/languages","stargazers_url":"https://api.github.com/repos/arthurnn/memcached/stargazers","contributors_url":"https://api.github.com/repos/arthurnn/memcached/contributors","subscribers_url":"https://api.github.com/repos/arthurnn/memcached/subscribers","subscription_url":"https://api.github.com/repos/arthurnn/memcached/subscription","commits_url":"https://api.github.com/repos/arthurnn/memcached/commits{/sha}","git_commits_url":"https://api.github.com/repos/arthurnn/memcached/git/commits{/sha}","comments_url":"https://api.github.com/repos/arthurnn/memcached/comments{/number}","issue_comment_url":"https://api.github.com/repos/arthurnn/memcached/issues/comments{/number}","contents_url":"https://api.github.com/repos/arthurnn/memcached/contents/{+path}","compare_url":"https://api.github.com/repos/arthurnn/memcached/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arthurnn/memcached/merges","archive_url":"https://api.github.com/repos/arthurnn/memcached/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arthurnn/memcached/downloads","issues_url":"https://api.github.com/repos/arthurnn/memcached/issues{/number}","pulls_url":"https://api.github.com/repos/arthurnn/memcached/pulls{/number}","milestones_url":"https://api.github.com/repos/arthurnn/memcached/milestones{/number}","notifications_url":"https://api.github.com/repos/arthurnn/memcached/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arthurnn/memcached/labels{/name}","releases_url":"https://api.github.com/repos/arthurnn/memcached/releases{/id}","deployments_url":"https://api.github.com/repos/arthurnn/memcached/deployments","created_at":"2008-06-11T20:40:22Z","updated_at":"2016-03-15T17:37:16Z","pushed_at":"2016-03-16T14:49:58Z","git_url":"git://github.com/arthurnn/memcached.git","ssh_url":"git@github.com:arthurnn/memcached.git","clone_url":"https://github.com/arthurnn/memcached.git","svn_url":"https://github.com/arthurnn/memcached","homepage":"","size":15129,"stargazers_count":404,"watchers_count":404,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":89,"mirror_url":null,"open_issues_count":9,"forks":89,"open_issues":9,"watchers":404,"default_branch":"master"}},"base":{"label":"arthurnn:master","ref":"master","sha":"c9fdb406eaac5321dfdf4feebfc595bb99705975","user":{"login":"arthurnn","id":833383,"avatar_url":"https://avatars.githubusercontent.com/u/833383?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurnn","html_url":"https://github.com/arthurnn","followers_url":"https://api.github.com/users/arthurnn/followers","following_url":"https://api.github.com/users/arthurnn/following{/other_user}","gists_url":"https://api.github.com/users/arthurnn/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurnn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurnn/subscriptions","organizations_url":"https://api.github.com/users/arthurnn/orgs","repos_url":"https://api.github.com/users/arthurnn/repos","events_url":"https://api.github.com/users/arthurnn/events{/privacy}","received_events_url":"https://api.github.com/users/arthurnn/received_events","type":"User","site_admin":true},"repo":{"id":24449,"name":"memcached","full_name":"arthurnn/memcached","owner":{"login":"arthurnn","id":833383,"avatar_url":"https://avatars.githubusercontent.com/u/833383?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurnn","html_url":"https://github.com/arthurnn","followers_url":"https://api.github.com/users/arthurnn/followers","following_url":"https://api.github.com/users/arthurnn/following{/other_user}","gists_url":"https://api.github.com/users/arthurnn/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurnn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurnn/subscriptions","organizations_url":"https://api.github.com/users/arthurnn/orgs","repos_url":"https://api.github.com/users/arthurnn/repos","events_url":"https://api.github.com/users/arthurnn/events{/privacy}","received_events_url":"https://api.github.com/users/arthurnn/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/arthurnn/memcached","description":"A Ruby interface to the libmemcached C client","fork":false,"url":"https://api.github.com/repos/arthurnn/memcached","forks_url":"https://api.github.com/repos/arthurnn/memcached/forks","keys_url":"https://api.github.com/repos/arthurnn/memcached/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arthurnn/memcached/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arthurnn/memcached/teams","hooks_url":"https://api.github.com/repos/arthurnn/memcached/hooks","issue_events_url":"https://api.github.com/repos/arthurnn/memcached/issues/events{/number}","events_url":"https://api.github.com/repos/arthurnn/memcached/events","assignees_url":"https://api.github.com/repos/arthurnn/memcached/assignees{/user}","branches_url":"https://api.github.com/repos/arthurnn/memcached/branches{/branch}","tags_url":"https://api.github.com/repos/arthurnn/memcached/tags","blobs_url":"https://api.github.com/repos/arthurnn/memcached/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arthurnn/memcached/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arthurnn/memcached/git/refs{/sha}","trees_url":"https://api.github.com/repos/arthurnn/memcached/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arthurnn/memcached/statuses/{sha}","languages_url":"https://api.github.com/repos/arthurnn/memcached/languages","stargazers_url":"https://api.github.com/repos/arthurnn/memcached/stargazers","contributors_url":"https://api.github.com/repos/arthurnn/memcached/contributors","subscribers_url":"https://api.github.com/repos/arthurnn/memcached/subscribers","subscription_url":"https://api.github.com/repos/arthurnn/memcached/subscription","commits_url":"https://api.github.com/repos/arthurnn/memcached/commits{/sha}","git_commits_url":"https://api.github.com/repos/arthurnn/memcached/git/commits{/sha}","comments_url":"https://api.github.com/repos/arthurnn/memcached/comments{/number}","issue_comment_url":"https://api.github.com/repos/arthurnn/memcached/issues/comments{/number}","contents_url":"https://api.github.com/repos/arthurnn/memcached/contents/{+path}","compare_url":"https://api.github.com/repos/arthurnn/memcached/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arthurnn/memcached/merges","archive_url":"https://api.github.com/repos/arthurnn/memcached/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arthurnn/memcached/downloads","issues_url":"https://api.github.com/repos/arthurnn/memcached/issues{/number}","pulls_url":"https://api.github.com/repos/arthurnn/memcached/pulls{/number}","milestones_url":"https://api.github.com/repos/arthurnn/memcached/milestones{/number}","notifications_url":"https://api.github.com/repos/arthurnn/memcached/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arthurnn/memcached/labels{/name}","releases_url":"https://api.github.com/repos/arthurnn/memcached/releases{/id}","deployments_url":"https://api.github.com/repos/arthurnn/memcached/deployments","created_at":"2008-06-11T20:40:22Z","updated_at":"2016-03-15T17:37:16Z","pushed_at":"2016-03-16T14:49:58Z","git_url":"git://github.com/arthurnn/memcached.git","ssh_url":"git@github.com:arthurnn/memcached.git","clone_url":"https://github.com/arthurnn/memcached.git","svn_url":"https://github.com/arthurnn/memcached","homepage":"","size":15129,"stargazers_count":404,"watchers_count":404,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":89,"mirror_url":null,"open_issues_count":9,"forks":89,"open_issues":9,"watchers":404,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/arthurnn/memcached/pulls/165"},"html":{"href":"https://github.com/arthurnn/memcached/pull/165"},"issue":{"href":"https://api.github.com/repos/arthurnn/memcached/issues/165"},"comments":{"href":"https://api.github.com/repos/arthurnn/memcached/issues/165/comments"},"review_comments":{"href":"https://api.github.com/repos/arthurnn/memcached/pulls/165/comments"},"review_comment":{"href":"https://api.github.com/repos/arthurnn/memcached/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/arthurnn/memcached/pulls/165/commits"},"statuses":{"href":"https://api.github.com/repos/arthurnn/memcached/statuses/7cc8a95610bd17a8a7be70994809fae699d49838"}}}}