Skip to content

Commit

Permalink
change aggregation_ops to internal type
Browse files Browse the repository at this point in the history
  • Loading branch information
a-veitch committed Aug 31, 2015
1 parent aafe972 commit 1c09acc
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 28 deletions.
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ cc_library(
"src/core/transport/stream_op.h",
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
"src/core/census/context.h",
"src/core/census/rpc_metric_id.h",
"src/core/httpcli/httpcli_security_connector.c",
Expand Down Expand Up @@ -514,6 +515,7 @@ cc_library(
"src/core/transport/stream_op.h",
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
"src/core/census/context.h",
"src/core/census/rpc_metric_id.h",
"src/core/surface/init_unsecure.c",
Expand Down Expand Up @@ -1271,6 +1273,7 @@ objc_library(
"src/core/transport/stream_op.h",
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
"src/core/census/context.h",
"src/core/census/rpc_metric_id.h",
],
Expand Down
1 change: 1 addition & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"include/grpc/census.h"
],
"headers": [
"src/core/census/aggregation.h",
"src/core/census/context.h",
"src/core/census/rpc_metric_id.h"
],
Expand Down
2 changes: 2 additions & 0 deletions gRPC.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ Pod::Spec.new do |s|
'src/core/transport/stream_op.h',
'src/core/transport/transport.h',
'src/core/transport/transport_impl.h',
'src/core/census/aggregation.h',
'src/core/census/context.h',
'src/core/census/rpc_metric_id.h',
'grpc/grpc_security.h',
Expand Down Expand Up @@ -520,6 +521,7 @@ Pod::Spec.new do |s|
'src/core/transport/stream_op.h',
'src/core/transport/transport.h',
'src/core/transport/transport_impl.h',
'src/core/census/aggregation.h',
'src/core/census/context.h',
'src/core/census/rpc_metric_id.h'

Expand Down
32 changes: 4 additions & 28 deletions include/grpc/census.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,34 +411,10 @@ typedef struct {
void census_record_values(census_context *context, census_value *values,
size_t nvalues);

/** Structure used to describe an aggregation type. */
typedef struct {
/* Create a new aggregation. The pointer returned can be used in future calls
to clone(), free(), record(), data() and reset(). */
void *(*create)(const void *create_arg);
/* Make a copy of an aggregation created by create() */
void *(*clone)(const void *aggregation);
/* Destroy an aggregation created by create() */
void (*free)(void *aggregation);
/* Record a new value against aggregation. */
void (*record)(void *aggregation, double value);
/* Return current aggregation data. The caller must cast this object into
the correct type for the aggregation result. The object returned can be
freed by using free_data(). */
void *(*data)(const void *aggregation);
/* free data returned by data() */
void (*free_data)(void *data);
/* Reset an aggregation to default (zero) values. */
void (*reset)(void *aggregation);
/* Merge 'from' aggregation into 'to'. Both aggregations must be compatible */
void (*merge)(void *to, const void *from);
/* Fill buffer with printable string version of aggregation contents. For
debugging only. Returns the number of bytes added to buffer (a value == n
implies the buffer was of insufficient size). */
size_t (*print)(const void *aggregation, char *buffer, size_t n);
} census_aggregation_ops;

/* Predefined aggregation types. */
/** Type representing a particular aggregation */
typedef struct census_aggregation_ops census_aggregation_ops;

/* Predefined aggregation types, for use with census_view_create(). */
extern census_aggregation_ops census_agg_sum;
extern census_aggregation_ops census_agg_distribution;
extern census_aggregation_ops census_agg_histogram;
Expand Down
66 changes: 66 additions & 0 deletions src/core/census/aggregation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

#include <stddef.h>

#ifndef GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H
#define GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H

/** Structure used to describe an aggregation type. */
struct census_aggregation_ops {
/* Create a new aggregation. The pointer returned can be used in future calls
to clone(), free(), record(), data() and reset(). */
void *(*create)(const void *create_arg);
/* Make a copy of an aggregation created by create() */
void *(*clone)(const void *aggregation);
/* Destroy an aggregation created by create() */
void (*free)(void *aggregation);
/* Record a new value against aggregation. */
void (*record)(void *aggregation, double value);
/* Return current aggregation data. The caller must cast this object into
the correct type for the aggregation result. The object returned can be
freed by using free_data(). */
void *(*data)(const void *aggregation);
/* free data returned by data() */
void (*free_data)(void *data);
/* Reset an aggregation to default (zero) values. */
void (*reset)(void *aggregation);
/* Merge 'from' aggregation into 'to'. Both aggregations must be compatible */
void (*merge)(void *to, const void *from);
/* Fill buffer with printable string version of aggregation contents. For
debugging only. Returns the number of bytes added to buffer (a value == n
implies the buffer was of insufficient size). */
size_t (*print)(const void *aggregation, char *buffer, size_t n);
};

#endif /* GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H */
1 change: 1 addition & 0 deletions tools/doxygen/Doxyfile.core.internal
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ src/core/transport/metadata.h \
src/core/transport/stream_op.h \
src/core/transport/transport.h \
src/core/transport/transport_impl.h \
src/core/census/aggregation.h \
src/core/census/context.h \
src/core/census/rpc_metric_id.h \
src/core/httpcli/httpcli_security_connector.c \
Expand Down
4 changes: 4 additions & 0 deletions tools/run_tests/sources_and_headers.json
Original file line number Diff line number Diff line change
Expand Up @@ -12229,6 +12229,7 @@
"include/grpc/grpc.h",
"include/grpc/grpc_security.h",
"include/grpc/status.h",
"src/core/census/aggregation.h",
"src/core/census/context.h",
"src/core/census/grpc_filter.h",
"src/core/census/rpc_metric_id.h",
Expand Down Expand Up @@ -12356,6 +12357,7 @@
"include/grpc/grpc.h",
"include/grpc/grpc_security.h",
"include/grpc/status.h",
"src/core/census/aggregation.h",
"src/core/census/context.c",
"src/core/census/context.h",
"src/core/census/grpc_context.c",
Expand Down Expand Up @@ -12707,6 +12709,7 @@
"include/grpc/compression.h",
"include/grpc/grpc.h",
"include/grpc/status.h",
"src/core/census/aggregation.h",
"src/core/census/context.h",
"src/core/census/grpc_filter.h",
"src/core/census/rpc_metric_id.h",
Expand Down Expand Up @@ -12820,6 +12823,7 @@
"include/grpc/compression.h",
"include/grpc/grpc.h",
"include/grpc/status.h",
"src/core/census/aggregation.h",
"src/core/census/context.c",
"src/core/census/context.h",
"src/core/census/grpc_context.c",
Expand Down
1 change: 1 addition & 0 deletions vsprojects/grpc/grpc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@
<ClInclude Include="..\..\src\core\transport\stream_op.h" />
<ClInclude Include="..\..\src\core\transport\transport.h" />
<ClInclude Include="..\..\src\core\transport\transport_impl.h" />
<ClInclude Include="..\..\src\core\census\aggregation.h" />
<ClInclude Include="..\..\src\core\census\context.h" />
<ClInclude Include="..\..\src\core\census\rpc_metric_id.h" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions vsprojects/grpc/grpc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,9 @@
<ClInclude Include="..\..\src\core\transport\transport_impl.h">
<Filter>src\core\transport</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\census\aggregation.h">
<Filter>src\core\census</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\census\context.h">
<Filter>src\core\census</Filter>
</ClInclude>
Expand Down
1 change: 1 addition & 0 deletions vsprojects/grpc_unsecure/grpc_unsecure.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
<ClInclude Include="..\..\src\core\transport\stream_op.h" />
<ClInclude Include="..\..\src\core\transport\transport.h" />
<ClInclude Include="..\..\src\core\transport\transport_impl.h" />
<ClInclude Include="..\..\src\core\census\aggregation.h" />
<ClInclude Include="..\..\src\core\census\context.h" />
<ClInclude Include="..\..\src\core\census\rpc_metric_id.h" />
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@
<ClInclude Include="..\..\src\core\transport\transport_impl.h">
<Filter>src\core\transport</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\census\aggregation.h">
<Filter>src\core\census</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\census\context.h">
<Filter>src\core\census</Filter>
</ClInclude>
Expand Down

0 comments on commit 1c09acc

Please sign in to comment.