aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/census/aggregation.h
blob: 1ba7953eccc3e448b33c03b63b6f47bf83db6e64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 *
 * Copyright 2015 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include <stddef.h>

#ifndef GRPC_CORE_EXT_CENSUS_AGGREGATION_H
#define GRPC_CORE_EXT_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_CORE_EXT_CENSUS_AGGREGATION_H */