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
c7299987
Commit
c7299987
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Plain Diff
Merge pull request #2073 from dgquintas/compression-metadata
Compression metadata
parents
ee6efaea
9e9aaa88
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/surface/call.c
+32
-0
32 additions, 0 deletions
src/core/surface/call.c
src/core/surface/channel.c
+9
-0
9 additions, 0 deletions
src/core/surface/channel.c
src/core/surface/channel.h
+1
-0
1 addition, 0 deletions
src/core/surface/channel.h
with
42 additions
and
0 deletions
src/core/surface/call.c
+
32
−
0
View file @
c7299987
...
...
@@ -214,6 +214,9 @@ struct grpc_call {
/* Received call statuses from various sources */
received_status
status
[
STATUS_SOURCE_COUNT
];
/** Compression level for the call */
grpc_compression_level
compression_level
;
/* Contexts for various subsystems (security, tracing, ...). */
grpc_call_context_element
context
[
GRPC_CONTEXT_COUNT
];
...
...
@@ -410,6 +413,11 @@ static void set_status_code(grpc_call *call, status_source source,
}
}
static
void
set_decode_compression_level
(
grpc_call
*
call
,
grpc_compression_level
clevel
)
{
call
->
compression_level
=
clevel
;
}
static
void
set_status_details
(
grpc_call
*
call
,
status_source
source
,
grpc_mdstr
*
status
)
{
if
(
call
->
status
[
source
].
details
!=
NULL
)
{
...
...
@@ -1169,6 +1177,28 @@ static gpr_uint32 decode_status(grpc_mdelem *md) {
return
status
;
}
/* just as for status above, we need to offset: metadata userdata can't hold a
* zero (null), which in this case is used to signal no compression */
#define COMPRESS_OFFSET 1
static
void
destroy_compression
(
void
*
ignored
)
{}
static
gpr_uint32
decode_compression
(
grpc_mdelem
*
md
)
{
grpc_compression_level
clevel
;
void
*
user_data
=
grpc_mdelem_get_user_data
(
md
,
destroy_status
);
if
(
user_data
)
{
clevel
=
((
grpc_compression_level
)(
gpr_intptr
)
user_data
)
-
COMPRESS_OFFSET
;
}
else
{
if
(
!
gpr_parse_bytes_to_uint32
(
grpc_mdstr_as_c_string
(
md
->
value
),
GPR_SLICE_LENGTH
(
md
->
value
->
slice
),
&
clevel
))
{
clevel
=
GRPC_COMPRESS_LEVEL_NONE
;
/* could not parse, no compression */
}
grpc_mdelem_set_user_data
(
md
,
destroy_compression
,
(
void
*
)(
gpr_intptr
)(
clevel
+
COMPRESS_OFFSET
));
}
return
clevel
;
}
static
void
recv_metadata
(
grpc_call
*
call
,
grpc_metadata_batch
*
md
)
{
grpc_linked_mdelem
*
l
;
grpc_metadata_array
*
dest
;
...
...
@@ -1184,6 +1214,8 @@ static void recv_metadata(grpc_call *call, grpc_metadata_batch *md) {
set_status_code
(
call
,
STATUS_FROM_WIRE
,
decode_status
(
md
));
}
else
if
(
key
==
grpc_channel_get_message_string
(
call
->
channel
))
{
set_status_details
(
call
,
STATUS_FROM_WIRE
,
grpc_mdstr_ref
(
md
->
value
));
}
else
if
(
key
==
grpc_channel_get_compresssion_level_string
(
call
->
channel
))
{
set_decode_compression_level
(
call
,
decode_compression
(
md
));
}
else
{
dest
=
&
call
->
buffered_metadata
[
is_trailing
];
if
(
dest
->
count
==
dest
->
capacity
)
{
...
...
This diff is collapsed.
Click to expand it.
src/core/surface/channel.c
+
9
−
0
View file @
c7299987
...
...
@@ -64,6 +64,7 @@ struct grpc_channel {
grpc_mdctx
*
metadata_context
;
/** mdstr for the grpc-status key */
grpc_mdstr
*
grpc_status_string
;
grpc_mdstr
*
grpc_compression_level_string
;
grpc_mdstr
*
grpc_message_string
;
grpc_mdstr
*
path_string
;
grpc_mdstr
*
authority_string
;
...
...
@@ -98,6 +99,8 @@ grpc_channel *grpc_channel_create_from_filters(
gpr_ref_init
(
&
channel
->
refs
,
1
+
is_client
);
channel
->
metadata_context
=
mdctx
;
channel
->
grpc_status_string
=
grpc_mdstr_from_string
(
mdctx
,
"grpc-status"
);
channel
->
grpc_compression_level_string
=
grpc_mdstr_from_string
(
mdctx
,
"grpc-compression-level"
);
channel
->
grpc_message_string
=
grpc_mdstr_from_string
(
mdctx
,
"grpc-message"
);
for
(
i
=
0
;
i
<
NUM_CACHED_STATUS_ELEMS
;
i
++
)
{
char
buf
[
GPR_LTOA_MIN_BUFSIZE
];
...
...
@@ -205,6 +208,7 @@ static void destroy_channel(void *p, int ok) {
grpc_mdelem_unref
(
channel
->
grpc_status_elem
[
i
]);
}
grpc_mdstr_unref
(
channel
->
grpc_status_string
);
grpc_mdstr_unref
(
channel
->
grpc_compression_level_string
);
grpc_mdstr_unref
(
channel
->
grpc_message_string
);
grpc_mdstr_unref
(
channel
->
path_string
);
grpc_mdstr_unref
(
channel
->
authority_string
);
...
...
@@ -269,6 +273,11 @@ grpc_mdstr *grpc_channel_get_status_string(grpc_channel *channel) {
return
channel
->
grpc_status_string
;
}
grpc_mdstr
*
grpc_channel_get_compresssion_level_string
(
grpc_channel
*
channel
)
{
return
channel
->
grpc_compression_level_string
;
}
grpc_mdelem
*
grpc_channel_get_reffed_status_elem
(
grpc_channel
*
channel
,
int
i
)
{
if
(
i
>=
0
&&
i
<
NUM_CACHED_STATUS_ELEMS
)
{
return
grpc_mdelem_ref
(
channel
->
grpc_status_elem
[
i
]);
...
...
This diff is collapsed.
Click to expand it.
src/core/surface/channel.h
+
1
−
0
View file @
c7299987
...
...
@@ -53,6 +53,7 @@ grpc_mdctx *grpc_channel_get_metadata_context(grpc_channel *channel);
grpc_mdelem
*
grpc_channel_get_reffed_status_elem
(
grpc_channel
*
channel
,
int
status_code
);
grpc_mdstr
*
grpc_channel_get_status_string
(
grpc_channel
*
channel
);
grpc_mdstr
*
grpc_channel_get_compresssion_level_string
(
grpc_channel
*
channel
);
grpc_mdstr
*
grpc_channel_get_message_string
(
grpc_channel
*
channel
);
gpr_uint32
grpc_channel_get_max_message_length
(
grpc_channel
*
channel
);
...
...
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