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
fbd06f72
Commit
fbd06f72
authored
7 years ago
by
Muxi Yan
Browse files
Options
Downloads
Patches
Plain Diff
Comments and fixes
parent
4f85558b
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/core/lib/compression/stream_compression.h
+10
-3
10 additions, 3 deletions
src/core/lib/compression/stream_compression.h
test/core/compression/stream_compression_test.c
+5
-5
5 additions, 5 deletions
test/core/compression/stream_compression_test.c
with
15 additions
and
8 deletions
src/core/lib/compression/stream_compression.h
+
10
−
3
View file @
fbd06f72
...
...
@@ -31,14 +31,15 @@ typedef struct grpc_stream_compression_context {
}
grpc_stream_compression_context
;
typedef
enum
grpc_stream_compression_method
{
GRPC_STREAM_COMPRESSION_COMPRESS
,
GRPC_STREAM_COMPRESSION_COMPRESS
=
0
,
GRPC_STREAM_COMPRESSION_DECOMPRESS
}
grpc_stream_compression_method
;
typedef
enum
grpc_stream_compression_flush
{
GRPC_STREAM_COMPRESSION_FLUSH_NONE
,
GRPC_STREAM_COMPRESSION_FLUSH_NONE
=
0
,
GRPC_STREAM_COMPRESSION_FLUSH_SYNC
,
GRPC_STREAM_COMPRESSION_FLUSH_FINISH
GRPC_STREAM_COMPRESSION_FLUSH_FINISH
,
GRPC_STREAM_COMPRESSION_FLUSH_COUNT
}
grpc_stream_compression_flush
;
/**
...
...
@@ -47,6 +48,12 @@ typedef enum grpc_stream_compression_flush {
* into \a out. If all the bytes in input buffer \a in are depleted and \a flush
* is not GRPC_STREAM_COMPRESSION_FLUSH_NONE, the corresponding flush method is
* executed. The total number of bytes emitted is outputed in \a output_size.
*
* A SYNC flush indicates that the entire messages in \a in can be decompressed
* from \a out. A FINISH flush implies a SYNC flush, and that any further
* compression will not be dependent on the state of the current context and any
* previous compressed bytes. It allows corresponding decompression context to
* be dropped when reaching this boundary.
*/
bool
grpc_stream_compress
(
grpc_stream_compression_context
*
ctx
,
grpc_slice_buffer
*
in
,
grpc_slice_buffer
*
out
,
...
...
This diff is collapsed.
Click to expand it.
test/core/compression/stream_compression_test.c
+
5
−
5
View file @
fbd06f72
...
...
@@ -72,7 +72,7 @@ static void test_stream_compression_simple_compress_decompress() {
size_t
output_size
;
GPR_ASSERT
(
grpc_stream_decompress
(
decompress_ctx
,
&
relay
,
&
sink
,
&
output_size
,
~
(
size_t
)
0
,
&
end_of_context
));
GPR_ASSERT
(
output_size
=
sizeof
(
test_str
)
-
1
);
GPR_ASSERT
(
output_size
=
=
sizeof
(
test_str
)
-
1
);
grpc_stream_compression_context_destroy
(
compress_ctx
);
grpc_stream_compression_context_destroy
(
decompress_ctx
);
...
...
@@ -107,7 +107,7 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint()
size_t
max_output_size
=
2
;
GPR_ASSERT
(
grpc_stream_decompress
(
decompress_ctx
,
&
relay
,
&
sink
,
&
output_size
,
max_output_size
,
&
end_of_context
));
GPR_ASSERT
(
output_size
=
max_output_size
);
GPR_ASSERT
(
output_size
=
=
max_output_size
);
GPR_ASSERT
(
end_of_context
==
false
);
grpc_slice
slice_recv
=
grpc_slice_buffer_take_first
(
&
sink
);
char
*
str_recv
=
(
char
*
)
GRPC_SLICE_START_PTR
(
slice_recv
);
...
...
@@ -118,8 +118,8 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint()
size_t
remaining_size
=
sizeof
(
test_str
)
-
1
-
max_output_size
;
GPR_ASSERT
(
grpc_stream_decompress
(
decompress_ctx
,
&
relay
,
&
sink
,
&
output_size
,
remaining_size
,
&
end_of_context
));
GPR_ASSERT
(
output_size
=
remaining_size
);
GPR_ASSERT
(
end_of_context
=
true
);
GPR_ASSERT
(
output_size
=
=
remaining_size
);
GPR_ASSERT
(
end_of_context
=
=
true
);
GPR_ASSERT
(
slice_buffer_equals_string
(
&
sink
,
test_str
+
max_output_size
));
...
...
@@ -152,7 +152,7 @@ test_stream_compression_simple_compress_decompress_with_large_data() {
size_t
output_size
;
GPR_ASSERT
(
grpc_stream_decompress
(
decompress_ctx
,
&
relay
,
&
sink
,
&
output_size
,
~
(
size_t
)
0
,
&
end_of_context
));
GPR_ASSERT
(
output_size
=
sizeof
(
test_str
)
-
1
);
GPR_ASSERT
(
output_size
=
=
sizeof
(
test_str
)
-
1
);
grpc_stream_compression_context_destroy
(
compress_ctx
);
grpc_stream_compression_context_destroy
(
decompress_ctx
);
...
...
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