Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hive-ruby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
hive-ruby
Commits
1d0b2114
Commit
1d0b2114
authored
6 years ago
by
Anthony Martin
Browse files
Options
Downloads
Patches
Plain Diff
make it easier to patch in alternative rpc clients
parent
aeb78088
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/steem/api.rb
+14
-3
14 additions, 3 deletions
lib/steem/api.rb
lib/steem/rpc/base_client.rb
+2
-2
2 additions, 2 deletions
lib/steem/rpc/base_client.rb
lib/steem/rpc/http_client.rb
+3
-2
3 additions, 2 deletions
lib/steem/rpc/http_client.rb
with
19 additions
and
7 deletions
lib/steem/api.rb
+
14
−
3
View file @
1d0b2114
...
@@ -39,8 +39,8 @@ module Steem
...
@@ -39,8 +39,8 @@ module Steem
attr_accessor
:chain
,
:methods
attr_accessor
:chain
,
:methods
# Use this for debugging naive thread handler.
# Use this for debugging naive thread handler.
# DEFAULT_RPC_CLIENT = RPC::BaseClient
# DEFAULT_RPC_CLIENT
_CLASS
= RPC::BaseClient
DEFAULT_RPC_CLIENT
=
RPC
::
ThreadSafeHttpClient
DEFAULT_RPC_CLIENT
_CLASS
=
RPC
::
ThreadSafeHttpClient
def
self
.
api_name
=
(
api_name
)
def
self
.
api_name
=
(
api_name
)
@api_name
=
api_name
.
to_s
.
@api_name
=
api_name
.
to_s
.
...
@@ -65,11 +65,22 @@ module Steem
...
@@ -65,11 +65,22 @@ module Steem
@jsonrpc
@jsonrpc
end
end
# Override this if you want to use your own client.
def
self
.
default_rpc_client_class
DEFAULT_RPC_CLIENT_CLASS
end
def
initialize
(
options
=
{})
def
initialize
(
options
=
{})
@chain
=
options
[
:chain
]
||
:steem
@chain
=
options
[
:chain
]
||
:steem
@error_pipe
=
options
[
:error_pipe
]
||
STDERR
@error_pipe
=
options
[
:error_pipe
]
||
STDERR
@api_name
=
self
.
class
.
api_name
||=
:condenser_api
@api_name
=
self
.
class
.
api_name
||=
:condenser_api
@rpc_client
=
options
[
:rpc_client
]
||
DEFAULT_RPC_CLIENT
.
new
(
options
.
merge
(
api_name:
@api_name
))
@rpc_client
=
if
!!
options
[
:rpc_client
]
options
[
:rpc_client
]
else
rpc_client_class
=
self
.
class
.
default_rpc_client_class
rpc_client_class
.
new
(
options
.
merge
(
api_name:
@api_name
))
end
if
@api_name
==
:jsonrpc
if
@api_name
==
:jsonrpc
Api
::
jsonrpc
=
self
Api
::
jsonrpc
=
self
...
...
This diff is collapsed.
Click to expand it.
lib/steem/rpc/base_client.rb
+
2
−
2
View file @
1d0b2114
...
@@ -3,7 +3,7 @@ module Steem
...
@@ -3,7 +3,7 @@ module Steem
class
BaseClient
class
BaseClient
include
ChainConfig
include
ChainConfig
attr_accessor
:chain
,
:error_pipe
attr_accessor
:url
,
:chain
,
:error_pipe
# @private
# @private
MAX_TIMEOUT_RETRY_COUNT
=
100
MAX_TIMEOUT_RETRY_COUNT
=
100
...
@@ -27,7 +27,7 @@ module Steem
...
@@ -27,7 +27,7 @@ module Steem
end
end
def
uri
def
uri
@uri
||=
URI
.
parse
(
@
url
)
@uri
||=
URI
.
parse
(
url
)
end
end
# Adds a request object to the stack. Usually, this method is called
# Adds a request object to the stack. Usually, this method is called
...
...
This diff is collapsed.
Click to expand it.
lib/steem/rpc/http_client.rb
+
3
−
2
View file @
1d0b2114
...
@@ -16,7 +16,8 @@ module Steem
...
@@ -16,7 +16,8 @@ module Steem
# http status code of 200 and HTML page.
# http status code of 200 and HTML page.
#
#
# @private
# @private
TIMEOUT_ERRORS
=
[
Net
::
OpenTimeout
,
Net
::
ReadTimeout
,
JSON
::
ParserError
]
TIMEOUT_ERRORS
=
[
Net
::
OpenTimeout
,
JSON
::
ParserError
,
Net
::
ReadTimeout
,
Errno
::
EBADF
,
Errno
::
ECONNREFUSED
,
IOError
]
# @private
# @private
POST_HEADERS
=
{
POST_HEADERS
=
{
...
@@ -66,7 +67,7 @@ module Steem
...
@@ -66,7 +67,7 @@ module Steem
end
end
if
request_object
.
size
>
JSON_RPC_BATCH_SIZE_MAXIMUM
if
request_object
.
size
>
JSON_RPC_BATCH_SIZE_MAXIMUM
raise
JsonRpcBatchMaximumSizeExceededError
,
'
Maximum json-rpc-batch is
50
elements.
'
raise
JsonRpcBatchMaximumSizeExceededError
,
"
Maximum json-rpc-batch is
#{
JSON_RPC_BATCH_SIZE_MAXIMUM
}
elements.
"
end
end
request
.
body
=
if
request_object
.
class
==
Hash
request
.
body
=
if
request_object
.
class
==
Hash
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment