Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
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
Service Desk
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
tci-gateway-module
Grpc
Commits
e389b043
Commit
e389b043
authored
9 years ago
by
murgatroid99
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug with composing credentials
parent
ca72d6cd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ruby/ext/grpc/rb_call_credentials.c
+20
-11
20 additions, 11 deletions
src/ruby/ext/grpc/rb_call_credentials.c
src/ruby/ext/grpc/rb_channel_credentials.c
+21
-11
21 additions, 11 deletions
src/ruby/ext/grpc/rb_channel_credentials.c
with
41 additions
and
22 deletions
src/ruby/ext/grpc/rb_call_credentials.c
+
20
−
11
View file @
e389b043
...
...
@@ -179,17 +179,6 @@ static rb_data_type_t grpc_rb_call_credentials_data_type = {
#endif
};
/* Creates a wrapping object for a given call credentials. This should only be
* called with grpc_call_credentials objects that are not already associated
* with any Ruby object */
VALUE
grpc_rb_wrap_call_credentials
(
grpc_call_credentials
*
c
)
{
if
(
c
==
NULL
)
{
return
Qnil
;
}
return
TypedData_Wrap_Struct
(
grpc_rb_cCallCredentials
,
&
grpc_rb_call_credentials_data_type
,
c
);
}
/* Allocates CallCredentials instances.
Provides safe initial defaults for the instance fields. */
static
VALUE
grpc_rb_call_credentials_alloc
(
VALUE
cls
)
{
...
...
@@ -199,6 +188,22 @@ static VALUE grpc_rb_call_credentials_alloc(VALUE cls) {
return
TypedData_Wrap_Struct
(
cls
,
&
grpc_rb_call_credentials_data_type
,
wrapper
);
}
/* Creates a wrapping object for a given call credentials. This should only be
* called with grpc_call_credentials objects that are not already associated
* with any Ruby object */
VALUE
grpc_rb_wrap_call_credentials
(
grpc_call_credentials
*
c
)
{
VALUE
rb_wrapper
;
grpc_rb_call_credentials
*
wrapper
;
if
(
c
==
NULL
)
{
return
Qnil
;
}
rb_wrapper
=
grpc_rb_call_credentials_alloc
(
grpc_rb_cCallCredentials
);
TypedData_Get_Struct
(
rb_wrapper
,
grpc_rb_call_credentials
,
&
grpc_rb_call_credentials_data_type
,
wrapper
);
wrapper
->
wrapped
=
c
;
return
rb_wrapper
;
}
/* Clones CallCredentials instances.
Gives CallCredentials a consistent implementation of Ruby's object copy/dup
protocol. */
...
...
@@ -246,6 +251,10 @@ static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
plugin
.
get_metadata
=
grpc_rb_call_credentials_plugin_get_metadata
;
plugin
.
destroy
=
grpc_rb_call_credentials_plugin_destroy
;
if
(
!
rb_obj_is_proc
(
proc
))
{
rb_raise
(
rb_eTypeError
,
"Argument to CallCredentials#new must be a proc"
);
return
Qnil
;
}
plugin
.
state
=
(
void
*
)
proc
;
plugin
.
type
=
""
;
...
...
This diff is collapsed.
Click to expand it.
src/ruby/ext/grpc/rb_channel_credentials.c
+
21
−
11
View file @
e389b043
...
...
@@ -37,6 +37,7 @@
#include
<grpc/grpc.h>
#include
<grpc/grpc_security.h>
#include
<grpc/support/log.h>
#include
"rb_call_credentials.h"
#include
"rb_grpc.h"
...
...
@@ -99,17 +100,6 @@ static rb_data_type_t grpc_rb_channel_credentials_data_type = {
#endif
};
/* Creates a wrapping object for a given channel credentials. This should only
* be called with grpc_channel_credentials objects that are not already
* associated with any Ruby object. */
VALUE
grpc_rb_wrap_channel_credentials
(
grpc_channel_credentials
*
c
)
{
if
(
c
==
NULL
)
{
return
Qnil
;
}
return
TypedData_Wrap_Struct
(
grpc_rb_cChannelCredentials
,
&
grpc_rb_channel_credentials_data_type
,
c
);
}
/* Allocates ChannelCredential instances.
Provides safe initial defaults for the instance fields. */
static
VALUE
grpc_rb_channel_credentials_alloc
(
VALUE
cls
)
{
...
...
@@ -119,6 +109,22 @@ static VALUE grpc_rb_channel_credentials_alloc(VALUE cls) {
return
TypedData_Wrap_Struct
(
cls
,
&
grpc_rb_channel_credentials_data_type
,
wrapper
);
}
/* Creates a wrapping object for a given channel credentials. This should only
* be called with grpc_channel_credentials objects that are not already
* associated with any Ruby object. */
VALUE
grpc_rb_wrap_channel_credentials
(
grpc_channel_credentials
*
c
)
{
VALUE
rb_wrapper
;
grpc_rb_channel_credentials
*
wrapper
;
if
(
c
==
NULL
)
{
return
Qnil
;
}
rb_wrapper
=
grpc_rb_channel_credentials_alloc
(
grpc_rb_cChannelCredentials
);
TypedData_Get_Struct
(
rb_wrapper
,
grpc_rb_channel_credentials
,
&
grpc_rb_channel_credentials_data_type
,
wrapper
);
wrapper
->
wrapped
=
c
;
return
rb_wrapper
;
}
/* Clones ChannelCredentials instances.
Gives ChannelCredentials a consistent implementation of Ruby's object copy/dup
protocol. */
...
...
@@ -222,6 +228,10 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
for
(
int
i
=
0
;
i
<
argc
;
i
++
)
{
other
=
grpc_rb_get_wrapped_call_credentials
(
argv
[
i
]);
creds
=
grpc_composite_channel_credentials_create
(
creds
,
other
,
NULL
);
if
(
creds
==
NULL
)
{
rb_raise
(
rb_eRuntimeError
,
"Failed to compose channel and call credentials"
);
}
}
return
grpc_rb_wrap_channel_credentials
(
creds
);
}
...
...
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