commit
248c4f5848
1192 changed files with 27416 additions and 52893 deletions
@ -1,5 +1,7 @@ |
||||
--- |
||||
Language: Cpp |
||||
BasedOnStyle: Google |
||||
DerivePointerAlignment: false |
||||
PointerAlignment: Left |
||||
... |
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,995 +0,0 @@ |
||||
# GRPC Node gyp file |
||||
# This currently builds the Node extension and dependencies |
||||
# This file has been automatically generated from a template file. |
||||
# Please look at the templates directory instead. |
||||
# This file can be regenerated from the template by running |
||||
# tools/buildgen/generate_projects.sh |
||||
|
||||
# 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. |
||||
|
||||
# Some of this file is built with the help of |
||||
# https://n8.io/converting-a-c-library-to-gyp/ |
||||
{ |
||||
'variables': { |
||||
'runtime%': 'node', |
||||
# Some Node installations use the system installation of OpenSSL, and on |
||||
# some systems, the system OpenSSL still does not have ALPN support. This |
||||
# will let users recompile gRPC to work without ALPN. |
||||
'grpc_alpn%': 'true', |
||||
# Indicates that the library should be built with gcov. |
||||
'grpc_gcov%': 'false', |
||||
# Indicates that the library should be built with compatibility for musl |
||||
# libc, so that it can run on Alpine Linux. This is only necessary if not |
||||
# building on Alpine Linux |
||||
'grpc_alpine%': 'false' |
||||
}, |
||||
'target_defaults': { |
||||
'configurations': { |
||||
'Release': { |
||||
'cflags': [ |
||||
'-O2', |
||||
], |
||||
'defines': [ |
||||
'NDEBUG', |
||||
], |
||||
}, |
||||
'Debug': { |
||||
'cflags': [ |
||||
'-O0', |
||||
], |
||||
'defines': [ |
||||
'_DEBUG', |
||||
'DEBUG', |
||||
], |
||||
}, |
||||
}, |
||||
'cflags': [ |
||||
'-g', |
||||
'-Wall', |
||||
'-Wextra', |
||||
'-Werror', |
||||
'-Wno-long-long', |
||||
'-Wno-unused-parameter', |
||||
'-DOSATOMIC_USE_INLINED=1', |
||||
'-Ithird_party/abseil-cpp', |
||||
], |
||||
'ldflags': [ |
||||
'-g', |
||||
], |
||||
'cflags_c': [ |
||||
'-Werror', |
||||
'-std=c99' |
||||
], |
||||
'cflags_cc': [ |
||||
'-Werror', |
||||
'-std=c++11' |
||||
], |
||||
'include_dirs': [ |
||||
'.', |
||||
'include' |
||||
], |
||||
'defines': [ |
||||
'GPR_BACKWARDS_COMPATIBILITY_MODE', |
||||
'GRPC_ARES=0', |
||||
'GRPC_UV' |
||||
], |
||||
'conditions': [ |
||||
['grpc_gcov=="true"', { |
||||
'cflags': [ |
||||
'-O0', |
||||
'-fprofile-arcs', |
||||
'-ftest-coverage', |
||||
'-Wno-return-type', |
||||
], |
||||
'defines': [ |
||||
'_DEBUG', |
||||
'DEBUG', |
||||
'GPR_GCOV', |
||||
], |
||||
'ldflags': [ |
||||
'-fprofile-arcs', |
||||
'-ftest-coverage', |
||||
'-rdynamic', |
||||
'-lstdc++', |
||||
], |
||||
}], |
||||
['grpc_alpine=="true"', { |
||||
'defines': [ |
||||
'GPR_MUSL_LIBC_COMPAT' |
||||
] |
||||
}], |
||||
['OS!="win" and runtime=="electron"', { |
||||
"defines": [ |
||||
'OPENSSL_NO_THREADS' |
||||
] |
||||
}], |
||||
# This is the condition for using boringssl |
||||
['OS=="win" or runtime=="electron"', { |
||||
"include_dirs": [ |
||||
"third_party/boringssl/include" |
||||
], |
||||
"defines": [ |
||||
'OPENSSL_NO_ASM' |
||||
] |
||||
}, { |
||||
'conditions': [ |
||||
["target_arch=='ia32'", { |
||||
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ] |
||||
}], |
||||
["target_arch=='x64'", { |
||||
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ] |
||||
}], |
||||
["target_arch=='arm'", { |
||||
"include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ] |
||||
}], |
||||
['grpc_alpn=="true"', { |
||||
'defines': [ |
||||
'TSI_OPENSSL_ALPN_SUPPORT=1' |
||||
], |
||||
}, { |
||||
'defines': [ |
||||
'TSI_OPENSSL_ALPN_SUPPORT=0' |
||||
], |
||||
}] |
||||
], |
||||
'include_dirs': [ |
||||
'<(node_root_dir)/deps/openssl/openssl/include', |
||||
] |
||||
}], |
||||
['OS == "win"', { |
||||
"include_dirs": [ |
||||
"third_party/zlib", |
||||
"third_party/cares/cares" |
||||
], |
||||
"defines": [ |
||||
'_WIN32_WINNT=0x0600', |
||||
'WIN32_LEAN_AND_MEAN', |
||||
'_HAS_EXCEPTIONS=0', |
||||
'UNICODE', |
||||
'_UNICODE', |
||||
'NOMINMAX', |
||||
], |
||||
"msvs_settings": { |
||||
'VCCLCompilerTool': { |
||||
'RuntimeLibrary': 1, # static debug |
||||
} |
||||
}, |
||||
"libraries": [ |
||||
"ws2_32" |
||||
] |
||||
}, { # OS != "win" |
||||
'include_dirs': [ |
||||
'<(node_root_dir)/deps/zlib', |
||||
'<(node_root_dir)/deps/cares/include' |
||||
] |
||||
}], |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'OTHER_CFLAGS': [ |
||||
'-g', |
||||
'-Wall', |
||||
'-Wextra', |
||||
'-Werror', |
||||
'-Wno-long-long', |
||||
'-Wno-unused-parameter', |
||||
'-DOSATOMIC_USE_INLINED=1', |
||||
'-Ithird_party/abseil-cpp', |
||||
], |
||||
'OTHER_CPLUSPLUSFLAGS': [ |
||||
'-g', |
||||
'-Wall', |
||||
'-Wextra', |
||||
'-Werror', |
||||
'-Wno-long-long', |
||||
'-Wno-unused-parameter', |
||||
'-DOSATOMIC_USE_INLINED=1', |
||||
'-Ithird_party/abseil-cpp', |
||||
'-stdlib=libc++', |
||||
'-std=c++11', |
||||
'-Wno-error=deprecated-declarations' |
||||
], |
||||
}, |
||||
}] |
||||
] |
||||
}, |
||||
'conditions': [ |
||||
['OS=="win" or runtime=="electron"', { |
||||
'targets': [ |
||||
{ |
||||
'target_name': 'boringssl', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
], |
||||
'sources': [ |
||||
'src/boringssl/err_data.c', |
||||
'third_party/boringssl/crypto/aes/aes.c', |
||||
'third_party/boringssl/crypto/aes/key_wrap.c', |
||||
'third_party/boringssl/crypto/aes/mode_wrappers.c', |
||||
'third_party/boringssl/crypto/asn1/a_bitstr.c', |
||||
'third_party/boringssl/crypto/asn1/a_bool.c', |
||||
'third_party/boringssl/crypto/asn1/a_d2i_fp.c', |
||||
'third_party/boringssl/crypto/asn1/a_dup.c', |
||||
'third_party/boringssl/crypto/asn1/a_enum.c', |
||||
'third_party/boringssl/crypto/asn1/a_gentm.c', |
||||
'third_party/boringssl/crypto/asn1/a_i2d_fp.c', |
||||
'third_party/boringssl/crypto/asn1/a_int.c', |
||||
'third_party/boringssl/crypto/asn1/a_mbstr.c', |
||||
'third_party/boringssl/crypto/asn1/a_object.c', |
||||
'third_party/boringssl/crypto/asn1/a_octet.c', |
||||
'third_party/boringssl/crypto/asn1/a_print.c', |
||||
'third_party/boringssl/crypto/asn1/a_strnid.c', |
||||
'third_party/boringssl/crypto/asn1/a_time.c', |
||||
'third_party/boringssl/crypto/asn1/a_type.c', |
||||
'third_party/boringssl/crypto/asn1/a_utctm.c', |
||||
'third_party/boringssl/crypto/asn1/a_utf8.c', |
||||
'third_party/boringssl/crypto/asn1/asn1_lib.c', |
||||
'third_party/boringssl/crypto/asn1/asn1_par.c', |
||||
'third_party/boringssl/crypto/asn1/asn_pack.c', |
||||
'third_party/boringssl/crypto/asn1/f_enum.c', |
||||
'third_party/boringssl/crypto/asn1/f_int.c', |
||||
'third_party/boringssl/crypto/asn1/f_string.c', |
||||
'third_party/boringssl/crypto/asn1/t_bitst.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_dec.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_enc.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_fre.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_new.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_typ.c', |
||||
'third_party/boringssl/crypto/asn1/tasn_utl.c', |
||||
'third_party/boringssl/crypto/asn1/time_support.c', |
||||
'third_party/boringssl/crypto/asn1/x_bignum.c', |
||||
'third_party/boringssl/crypto/asn1/x_long.c', |
||||
'third_party/boringssl/crypto/base64/base64.c', |
||||
'third_party/boringssl/crypto/bio/bio.c', |
||||
'third_party/boringssl/crypto/bio/bio_mem.c', |
||||
'third_party/boringssl/crypto/bio/connect.c', |
||||
'third_party/boringssl/crypto/bio/fd.c', |
||||
'third_party/boringssl/crypto/bio/file.c', |
||||
'third_party/boringssl/crypto/bio/hexdump.c', |
||||
'third_party/boringssl/crypto/bio/pair.c', |
||||
'third_party/boringssl/crypto/bio/printf.c', |
||||
'third_party/boringssl/crypto/bio/socket.c', |
||||
'third_party/boringssl/crypto/bio/socket_helper.c', |
||||
'third_party/boringssl/crypto/bn/add.c', |
||||
'third_party/boringssl/crypto/bn/asm/x86_64-gcc.c', |
||||
'third_party/boringssl/crypto/bn/bn.c', |
||||
'third_party/boringssl/crypto/bn/bn_asn1.c', |
||||
'third_party/boringssl/crypto/bn/cmp.c', |
||||
'third_party/boringssl/crypto/bn/convert.c', |
||||
'third_party/boringssl/crypto/bn/ctx.c', |
||||
'third_party/boringssl/crypto/bn/div.c', |
||||
'third_party/boringssl/crypto/bn/exponentiation.c', |
||||
'third_party/boringssl/crypto/bn/gcd.c', |
||||
'third_party/boringssl/crypto/bn/generic.c', |
||||
'third_party/boringssl/crypto/bn/kronecker.c', |
||||
'third_party/boringssl/crypto/bn/montgomery.c', |
||||
'third_party/boringssl/crypto/bn/montgomery_inv.c', |
||||
'third_party/boringssl/crypto/bn/mul.c', |
||||
'third_party/boringssl/crypto/bn/prime.c', |
||||
'third_party/boringssl/crypto/bn/random.c', |
||||
'third_party/boringssl/crypto/bn/rsaz_exp.c', |
||||
'third_party/boringssl/crypto/bn/shift.c', |
||||
'third_party/boringssl/crypto/bn/sqrt.c', |
||||
'third_party/boringssl/crypto/buf/buf.c', |
||||
'third_party/boringssl/crypto/bytestring/asn1_compat.c', |
||||
'third_party/boringssl/crypto/bytestring/ber.c', |
||||
'third_party/boringssl/crypto/bytestring/cbb.c', |
||||
'third_party/boringssl/crypto/bytestring/cbs.c', |
||||
'third_party/boringssl/crypto/chacha/chacha.c', |
||||
'third_party/boringssl/crypto/cipher/aead.c', |
||||
'third_party/boringssl/crypto/cipher/cipher.c', |
||||
'third_party/boringssl/crypto/cipher/derive_key.c', |
||||
'third_party/boringssl/crypto/cipher/e_aes.c', |
||||
'third_party/boringssl/crypto/cipher/e_chacha20poly1305.c', |
||||
'third_party/boringssl/crypto/cipher/e_des.c', |
||||
'third_party/boringssl/crypto/cipher/e_null.c', |
||||
'third_party/boringssl/crypto/cipher/e_rc2.c', |
||||
'third_party/boringssl/crypto/cipher/e_rc4.c', |
||||
'third_party/boringssl/crypto/cipher/e_ssl3.c', |
||||
'third_party/boringssl/crypto/cipher/e_tls.c', |
||||
'third_party/boringssl/crypto/cipher/tls_cbc.c', |
||||
'third_party/boringssl/crypto/cmac/cmac.c', |
||||
'third_party/boringssl/crypto/conf/conf.c', |
||||
'third_party/boringssl/crypto/cpu-aarch64-linux.c', |
||||
'third_party/boringssl/crypto/cpu-arm-linux.c', |
||||
'third_party/boringssl/crypto/cpu-arm.c', |
||||
'third_party/boringssl/crypto/cpu-intel.c', |
||||
'third_party/boringssl/crypto/cpu-ppc64le.c', |
||||
'third_party/boringssl/crypto/crypto.c', |
||||
'third_party/boringssl/crypto/curve25519/curve25519.c', |
||||
'third_party/boringssl/crypto/curve25519/spake25519.c', |
||||
'third_party/boringssl/crypto/curve25519/x25519-x86_64.c', |
||||
'third_party/boringssl/crypto/des/des.c', |
||||
'third_party/boringssl/crypto/dh/check.c', |
||||
'third_party/boringssl/crypto/dh/dh.c', |
||||
'third_party/boringssl/crypto/dh/dh_asn1.c', |
||||
'third_party/boringssl/crypto/dh/params.c', |
||||
'third_party/boringssl/crypto/digest/digest.c', |
||||
'third_party/boringssl/crypto/digest/digests.c', |
||||
'third_party/boringssl/crypto/dsa/dsa.c', |
||||
'third_party/boringssl/crypto/dsa/dsa_asn1.c', |
||||
'third_party/boringssl/crypto/ec/ec.c', |
||||
'third_party/boringssl/crypto/ec/ec_asn1.c', |
||||
'third_party/boringssl/crypto/ec/ec_key.c', |
||||
'third_party/boringssl/crypto/ec/ec_montgomery.c', |
||||
'third_party/boringssl/crypto/ec/oct.c', |
||||
'third_party/boringssl/crypto/ec/p224-64.c', |
||||
'third_party/boringssl/crypto/ec/p256-64.c', |
||||
'third_party/boringssl/crypto/ec/p256-x86_64.c', |
||||
'third_party/boringssl/crypto/ec/simple.c', |
||||
'third_party/boringssl/crypto/ec/util-64.c', |
||||
'third_party/boringssl/crypto/ec/wnaf.c', |
||||
'third_party/boringssl/crypto/ecdh/ecdh.c', |
||||
'third_party/boringssl/crypto/ecdsa/ecdsa.c', |
||||
'third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c', |
||||
'third_party/boringssl/crypto/engine/engine.c', |
||||
'third_party/boringssl/crypto/err/err.c', |
||||
'third_party/boringssl/crypto/evp/digestsign.c', |
||||
'third_party/boringssl/crypto/evp/evp.c', |
||||
'third_party/boringssl/crypto/evp/evp_asn1.c', |
||||
'third_party/boringssl/crypto/evp/evp_ctx.c', |
||||
'third_party/boringssl/crypto/evp/p_dsa_asn1.c', |
||||
'third_party/boringssl/crypto/evp/p_ec.c', |
||||
'third_party/boringssl/crypto/evp/p_ec_asn1.c', |
||||
'third_party/boringssl/crypto/evp/p_rsa.c', |
||||
'third_party/boringssl/crypto/evp/p_rsa_asn1.c', |
||||
'third_party/boringssl/crypto/evp/pbkdf.c', |
||||
'third_party/boringssl/crypto/evp/print.c', |
||||
'third_party/boringssl/crypto/evp/sign.c', |
||||
'third_party/boringssl/crypto/ex_data.c', |
||||
'third_party/boringssl/crypto/hkdf/hkdf.c', |
||||
'third_party/boringssl/crypto/hmac/hmac.c', |
||||
'third_party/boringssl/crypto/lhash/lhash.c', |
||||
'third_party/boringssl/crypto/md4/md4.c', |
||||
'third_party/boringssl/crypto/md5/md5.c', |
||||
'third_party/boringssl/crypto/mem.c', |
||||
'third_party/boringssl/crypto/modes/cbc.c', |
||||
'third_party/boringssl/crypto/modes/cfb.c', |
||||
'third_party/boringssl/crypto/modes/ctr.c', |
||||
'third_party/boringssl/crypto/modes/gcm.c', |
||||
'third_party/boringssl/crypto/modes/ofb.c', |
||||
'third_party/boringssl/crypto/modes/polyval.c', |
||||
'third_party/boringssl/crypto/obj/obj.c', |
||||
'third_party/boringssl/crypto/obj/obj_xref.c', |
||||
'third_party/boringssl/crypto/pem/pem_all.c', |
||||
'third_party/boringssl/crypto/pem/pem_info.c', |
||||
'third_party/boringssl/crypto/pem/pem_lib.c', |
||||
'third_party/boringssl/crypto/pem/pem_oth.c', |
||||
'third_party/boringssl/crypto/pem/pem_pk8.c', |
||||
'third_party/boringssl/crypto/pem/pem_pkey.c', |
||||
'third_party/boringssl/crypto/pem/pem_x509.c', |
||||
'third_party/boringssl/crypto/pem/pem_xaux.c', |
||||
'third_party/boringssl/crypto/pkcs8/p5_pbev2.c', |
||||
'third_party/boringssl/crypto/pkcs8/p8_pkey.c', |
||||
'third_party/boringssl/crypto/pkcs8/pkcs8.c', |
||||
'third_party/boringssl/crypto/poly1305/poly1305.c', |
||||
'third_party/boringssl/crypto/poly1305/poly1305_arm.c', |
||||
'third_party/boringssl/crypto/poly1305/poly1305_vec.c', |
||||
'third_party/boringssl/crypto/pool/pool.c', |
||||
'third_party/boringssl/crypto/rand/deterministic.c', |
||||
'third_party/boringssl/crypto/rand/fuchsia.c', |
||||
'third_party/boringssl/crypto/rand/rand.c', |
||||
'third_party/boringssl/crypto/rand/urandom.c', |
||||
'third_party/boringssl/crypto/rand/windows.c', |
||||
'third_party/boringssl/crypto/rc4/rc4.c', |
||||
'third_party/boringssl/crypto/refcount_c11.c', |
||||
'third_party/boringssl/crypto/refcount_lock.c', |
||||
'third_party/boringssl/crypto/rsa/blinding.c', |
||||
'third_party/boringssl/crypto/rsa/padding.c', |
||||
'third_party/boringssl/crypto/rsa/rsa.c', |
||||
'third_party/boringssl/crypto/rsa/rsa_asn1.c', |
||||
'third_party/boringssl/crypto/rsa/rsa_impl.c', |
||||
'third_party/boringssl/crypto/sha/sha1-altivec.c', |
||||
'third_party/boringssl/crypto/sha/sha1.c', |
||||
'third_party/boringssl/crypto/sha/sha256.c', |
||||
'third_party/boringssl/crypto/sha/sha512.c', |
||||
'third_party/boringssl/crypto/stack/stack.c', |
||||
'third_party/boringssl/crypto/thread.c', |
||||
'third_party/boringssl/crypto/thread_none.c', |
||||
'third_party/boringssl/crypto/thread_pthread.c', |
||||
'third_party/boringssl/crypto/thread_win.c', |
||||
'third_party/boringssl/crypto/x509/a_digest.c', |
||||
'third_party/boringssl/crypto/x509/a_sign.c', |
||||
'third_party/boringssl/crypto/x509/a_strex.c', |
||||
'third_party/boringssl/crypto/x509/a_verify.c', |
||||
'third_party/boringssl/crypto/x509/algorithm.c', |
||||
'third_party/boringssl/crypto/x509/asn1_gen.c', |
||||
'third_party/boringssl/crypto/x509/by_dir.c', |
||||
'third_party/boringssl/crypto/x509/by_file.c', |
||||
'third_party/boringssl/crypto/x509/i2d_pr.c', |
||||
'third_party/boringssl/crypto/x509/pkcs7.c', |
||||
'third_party/boringssl/crypto/x509/rsa_pss.c', |
||||
'third_party/boringssl/crypto/x509/t_crl.c', |
||||
'third_party/boringssl/crypto/x509/t_req.c', |
||||
'third_party/boringssl/crypto/x509/t_x509.c', |
||||
'third_party/boringssl/crypto/x509/t_x509a.c', |
||||
'third_party/boringssl/crypto/x509/x509.c', |
||||
'third_party/boringssl/crypto/x509/x509_att.c', |
||||
'third_party/boringssl/crypto/x509/x509_cmp.c', |
||||
'third_party/boringssl/crypto/x509/x509_d2.c', |
||||
'third_party/boringssl/crypto/x509/x509_def.c', |
||||
'third_party/boringssl/crypto/x509/x509_ext.c', |
||||
'third_party/boringssl/crypto/x509/x509_lu.c', |
||||
'third_party/boringssl/crypto/x509/x509_obj.c', |
||||
'third_party/boringssl/crypto/x509/x509_r2x.c', |
||||
'third_party/boringssl/crypto/x509/x509_req.c', |
||||
'third_party/boringssl/crypto/x509/x509_set.c', |
||||
'third_party/boringssl/crypto/x509/x509_trs.c', |
||||
'third_party/boringssl/crypto/x509/x509_txt.c', |
||||
'third_party/boringssl/crypto/x509/x509_v3.c', |
||||
'third_party/boringssl/crypto/x509/x509_vfy.c', |
||||
'third_party/boringssl/crypto/x509/x509_vpm.c', |
||||
'third_party/boringssl/crypto/x509/x509cset.c', |
||||
'third_party/boringssl/crypto/x509/x509name.c', |
||||
'third_party/boringssl/crypto/x509/x509rset.c', |
||||
'third_party/boringssl/crypto/x509/x509spki.c', |
||||
'third_party/boringssl/crypto/x509/x509type.c', |
||||
'third_party/boringssl/crypto/x509/x_algor.c', |
||||
'third_party/boringssl/crypto/x509/x_all.c', |
||||
'third_party/boringssl/crypto/x509/x_attrib.c', |
||||
'third_party/boringssl/crypto/x509/x_crl.c', |
||||
'third_party/boringssl/crypto/x509/x_exten.c', |
||||
'third_party/boringssl/crypto/x509/x_info.c', |
||||
'third_party/boringssl/crypto/x509/x_name.c', |
||||
'third_party/boringssl/crypto/x509/x_pkey.c', |
||||
'third_party/boringssl/crypto/x509/x_pubkey.c', |
||||
'third_party/boringssl/crypto/x509/x_req.c', |
||||
'third_party/boringssl/crypto/x509/x_sig.c', |
||||
'third_party/boringssl/crypto/x509/x_spki.c', |
||||
'third_party/boringssl/crypto/x509/x_val.c', |
||||
'third_party/boringssl/crypto/x509/x_x509.c', |
||||
'third_party/boringssl/crypto/x509/x_x509a.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_cache.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_data.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_lib.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_map.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_node.c', |
||||
'third_party/boringssl/crypto/x509v3/pcy_tree.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_akey.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_akeya.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_alt.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_bcons.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_bitst.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_conf.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_cpols.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_crld.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_enum.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_extku.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_genn.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_ia5.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_info.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_int.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_lib.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_ncons.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pci.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pcia.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pcons.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pku.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_pmaps.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_prn.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_purp.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_skey.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_sxnet.c', |
||||
'third_party/boringssl/crypto/x509v3/v3_utl.c', |
||||
'third_party/boringssl/ssl/bio_ssl.c', |
||||
'third_party/boringssl/ssl/custom_extensions.c', |
||||
'third_party/boringssl/ssl/d1_both.c', |
||||
'third_party/boringssl/ssl/d1_lib.c', |
||||
'third_party/boringssl/ssl/d1_pkt.c', |
||||
'third_party/boringssl/ssl/d1_srtp.c', |
||||
'third_party/boringssl/ssl/dtls_method.c', |
||||
'third_party/boringssl/ssl/dtls_record.c', |
||||
'third_party/boringssl/ssl/handshake_client.c', |
||||
'third_party/boringssl/ssl/handshake_server.c', |
||||
'third_party/boringssl/ssl/s3_both.c', |
||||
'third_party/boringssl/ssl/s3_lib.c', |
||||
'third_party/boringssl/ssl/s3_pkt.c', |
||||
'third_party/boringssl/ssl/ssl_aead_ctx.c', |
||||
'third_party/boringssl/ssl/ssl_asn1.c', |
||||
'third_party/boringssl/ssl/ssl_buffer.c', |
||||
'third_party/boringssl/ssl/ssl_cert.c', |
||||
'third_party/boringssl/ssl/ssl_cipher.c', |
||||
'third_party/boringssl/ssl/ssl_ecdh.c', |
||||
'third_party/boringssl/ssl/ssl_file.c', |
||||
'third_party/boringssl/ssl/ssl_lib.c', |
||||
'third_party/boringssl/ssl/ssl_privkey.c', |
||||
'third_party/boringssl/ssl/ssl_privkey_cc.cc', |
||||
'third_party/boringssl/ssl/ssl_session.c', |
||||
'third_party/boringssl/ssl/ssl_stat.c', |
||||
'third_party/boringssl/ssl/ssl_transcript.c', |
||||
'third_party/boringssl/ssl/ssl_x509.c', |
||||
'third_party/boringssl/ssl/t1_enc.c', |
||||
'third_party/boringssl/ssl/t1_lib.c', |
||||
'third_party/boringssl/ssl/tls13_both.c', |
||||
'third_party/boringssl/ssl/tls13_client.c', |
||||
'third_party/boringssl/ssl/tls13_enc.c', |
||||
'third_party/boringssl/ssl/tls13_server.c', |
||||
'third_party/boringssl/ssl/tls_method.c', |
||||
'third_party/boringssl/ssl/tls_record.c', |
||||
], |
||||
'conditions': [ |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
] |
||||
}, |
||||
], |
||||
}], |
||||
['OS == "win" and runtime!="electron"', { |
||||
'targets': [ |
||||
{ |
||||
# IMPORTANT WINDOWS BUILD INFORMATION |
||||
# This library does not build on Windows without modifying the Node |
||||
# development packages that node-gyp downloads in order to build. |
||||
# Due to https://github.com/nodejs/node/issues/4932, the headers for |
||||
# BoringSSL conflict with the OpenSSL headers included by default |
||||
# when including the Node headers. The remedy for this is to remove |
||||
# the OpenSSL headers, from the downloaded Node development package, |
||||
# which is typically located in `.node-gyp` in your home directory. |
||||
# |
||||
# This is not true of Electron, which does not have OpenSSL headers. |
||||
'target_name': 'WINDOWS_BUILD_WARNING', |
||||
'rules': [ |
||||
{ |
||||
'rule_name': 'WINDOWS_BUILD_WARNING', |
||||
'extension': 'S', |
||||
'inputs': [ |
||||
'package.json' |
||||
], |
||||
'outputs': [ |
||||
'ignore_this_part' |
||||
], |
||||
'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/'] |
||||
} |
||||
] |
||||
}, |
||||
] |
||||
}], |
||||
['OS == "win"', { |
||||
'targets': [ |
||||
# Only want to compile zlib under Windows |
||||
{ |
||||
'target_name': 'z', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
], |
||||
'sources': [ |
||||
'third_party/zlib/adler32.c', |
||||
'third_party/zlib/compress.c', |
||||
'third_party/zlib/crc32.c', |
||||
'third_party/zlib/deflate.c', |
||||
'third_party/zlib/gzclose.c', |
||||
'third_party/zlib/gzlib.c', |
||||
'third_party/zlib/gzread.c', |
||||
'third_party/zlib/gzwrite.c', |
||||
'third_party/zlib/infback.c', |
||||
'third_party/zlib/inffast.c', |
||||
'third_party/zlib/inflate.c', |
||||
'third_party/zlib/inftrees.c', |
||||
'third_party/zlib/trees.c', |
||||
'third_party/zlib/uncompr.c', |
||||
'third_party/zlib/zutil.c', |
||||
] |
||||
}, |
||||
] |
||||
}] |
||||
], |
||||
'targets': [ |
||||
{ |
||||
'target_name': 'gpr', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
], |
||||
'sources': [ |
||||
'src/core/lib/profiling/basic_timers.cc', |
||||
'src/core/lib/profiling/stap_timers.cc', |
||||
'src/core/lib/support/alloc.cc', |
||||
'src/core/lib/support/arena.cc', |
||||
'src/core/lib/support/atm.cc', |
||||
'src/core/lib/support/avl.cc', |
||||
'src/core/lib/support/cmdline.cc', |
||||
'src/core/lib/support/cpu_iphone.cc', |
||||
'src/core/lib/support/cpu_linux.cc', |
||||
'src/core/lib/support/cpu_posix.cc', |
||||
'src/core/lib/support/cpu_windows.cc', |
||||
'src/core/lib/support/env_linux.cc', |
||||
'src/core/lib/support/env_posix.cc', |
||||
'src/core/lib/support/env_windows.cc', |
||||
'src/core/lib/support/histogram.cc', |
||||
'src/core/lib/support/host_port.cc', |
||||
'src/core/lib/support/log.cc', |
||||
'src/core/lib/support/log_android.cc', |
||||
'src/core/lib/support/log_linux.cc', |
||||
'src/core/lib/support/log_posix.cc', |
||||
'src/core/lib/support/log_windows.cc', |
||||
'src/core/lib/support/mpscq.cc', |
||||
'src/core/lib/support/murmur_hash.cc', |
||||
'src/core/lib/support/stack_lockfree.cc', |
||||
'src/core/lib/support/string.cc', |
||||
'src/core/lib/support/string_posix.cc', |
||||
'src/core/lib/support/string_util_windows.cc', |
||||
'src/core/lib/support/string_windows.cc', |
||||
'src/core/lib/support/subprocess_posix.cc', |
||||
'src/core/lib/support/subprocess_windows.cc', |
||||
'src/core/lib/support/sync.cc', |
||||
'src/core/lib/support/sync_posix.cc', |
||||
'src/core/lib/support/sync_windows.cc', |
||||
'src/core/lib/support/thd.cc', |
||||
'src/core/lib/support/thd_posix.cc', |
||||
'src/core/lib/support/thd_windows.cc', |
||||
'src/core/lib/support/time.cc', |
||||
'src/core/lib/support/time_posix.cc', |
||||
'src/core/lib/support/time_precise.cc', |
||||
'src/core/lib/support/time_windows.cc', |
||||
'src/core/lib/support/tls_pthread.cc', |
||||
'src/core/lib/support/tmpfile_msys.cc', |
||||
'src/core/lib/support/tmpfile_posix.cc', |
||||
'src/core/lib/support/tmpfile_windows.cc', |
||||
'src/core/lib/support/wrap_memcpy.cc', |
||||
], |
||||
'conditions': [ |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
] |
||||
}, |
||||
{ |
||||
'target_name': 'grpc', |
||||
'product_prefix': 'lib', |
||||
'type': 'static_library', |
||||
'dependencies': [ |
||||
'gpr', |
||||
], |
||||
'sources': [ |
||||
'src/core/lib/surface/init.cc', |
||||
'src/core/lib/backoff/backoff.cc', |
||||
'src/core/lib/channel/channel_args.cc', |
||||
'src/core/lib/channel/channel_stack.cc', |
||||
'src/core/lib/channel/channel_stack_builder.cc', |
||||
'src/core/lib/channel/connected_channel.cc', |
||||
'src/core/lib/channel/handshaker.cc', |
||||
'src/core/lib/channel/handshaker_factory.cc', |
||||
'src/core/lib/channel/handshaker_registry.cc', |
||||
'src/core/lib/compression/compression.cc', |
||||
'src/core/lib/compression/message_compress.cc', |
||||
'src/core/lib/compression/stream_compression.cc', |
||||
'src/core/lib/compression/stream_compression_gzip.cc', |
||||
'src/core/lib/compression/stream_compression_identity.cc', |
||||
'src/core/lib/debug/stats.cc', |
||||
'src/core/lib/debug/stats_data.cc', |
||||
'src/core/lib/http/format_request.cc', |
||||
'src/core/lib/http/httpcli.cc', |
||||
'src/core/lib/http/parser.cc', |
||||
'src/core/lib/iomgr/call_combiner.cc', |
||||
'src/core/lib/iomgr/closure.cc', |
||||
'src/core/lib/iomgr/combiner.cc', |
||||
'src/core/lib/iomgr/endpoint.cc', |
||||
'src/core/lib/iomgr/endpoint_pair_posix.cc', |
||||
'src/core/lib/iomgr/endpoint_pair_uv.cc', |
||||
'src/core/lib/iomgr/endpoint_pair_windows.cc', |
||||
'src/core/lib/iomgr/error.cc', |
||||
'src/core/lib/iomgr/ev_epoll1_linux.cc', |
||||
'src/core/lib/iomgr/ev_epollex_linux.cc', |
||||
'src/core/lib/iomgr/ev_epollsig_linux.cc', |
||||
'src/core/lib/iomgr/ev_poll_posix.cc', |
||||
'src/core/lib/iomgr/ev_posix.cc', |
||||
'src/core/lib/iomgr/ev_windows.cc', |
||||
'src/core/lib/iomgr/exec_ctx.cc', |
||||
'src/core/lib/iomgr/executor.cc', |
||||
'src/core/lib/iomgr/gethostname_fallback.cc', |
||||
'src/core/lib/iomgr/gethostname_host_name_max.cc', |
||||
'src/core/lib/iomgr/gethostname_sysconf.cc', |
||||
'src/core/lib/iomgr/iocp_windows.cc', |
||||
'src/core/lib/iomgr/iomgr.cc', |
||||
'src/core/lib/iomgr/iomgr_posix.cc', |
||||
'src/core/lib/iomgr/iomgr_uv.cc', |
||||
'src/core/lib/iomgr/iomgr_windows.cc', |
||||
'src/core/lib/iomgr/is_epollexclusive_available.cc', |
||||
'src/core/lib/iomgr/load_file.cc', |
||||
'src/core/lib/iomgr/lockfree_event.cc', |
||||
'src/core/lib/iomgr/network_status_tracker.cc', |
||||
'src/core/lib/iomgr/polling_entity.cc', |
||||
'src/core/lib/iomgr/pollset_set_uv.cc', |
||||
'src/core/lib/iomgr/pollset_set_windows.cc', |
||||
'src/core/lib/iomgr/pollset_uv.cc', |
||||
'src/core/lib/iomgr/pollset_windows.cc', |
||||
'src/core/lib/iomgr/resolve_address_posix.cc', |
||||
'src/core/lib/iomgr/resolve_address_uv.cc', |
||||
'src/core/lib/iomgr/resolve_address_windows.cc', |
||||
'src/core/lib/iomgr/resource_quota.cc', |
||||
'src/core/lib/iomgr/sockaddr_utils.cc', |
||||
'src/core/lib/iomgr/socket_factory_posix.cc', |
||||
'src/core/lib/iomgr/socket_mutator.cc', |
||||
'src/core/lib/iomgr/socket_utils_common_posix.cc', |
||||
'src/core/lib/iomgr/socket_utils_linux.cc', |
||||
'src/core/lib/iomgr/socket_utils_posix.cc', |
||||
'src/core/lib/iomgr/socket_utils_uv.cc', |
||||
'src/core/lib/iomgr/socket_utils_windows.cc', |
||||
'src/core/lib/iomgr/socket_windows.cc', |
||||
'src/core/lib/iomgr/tcp_client_posix.cc', |
||||
'src/core/lib/iomgr/tcp_client_uv.cc', |
||||
'src/core/lib/iomgr/tcp_client_windows.cc', |
||||
'src/core/lib/iomgr/tcp_posix.cc', |
||||
'src/core/lib/iomgr/tcp_server_posix.cc', |
||||
'src/core/lib/iomgr/tcp_server_utils_posix_common.cc', |
||||
'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc', |
||||
'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc', |
||||
'src/core/lib/iomgr/tcp_server_uv.cc', |
||||
'src/core/lib/iomgr/tcp_server_windows.cc', |
||||
'src/core/lib/iomgr/tcp_uv.cc', |
||||
'src/core/lib/iomgr/tcp_windows.cc', |
||||
'src/core/lib/iomgr/time_averaged_stats.cc', |
||||
'src/core/lib/iomgr/timer_generic.cc', |
||||
'src/core/lib/iomgr/timer_heap.cc', |
||||
'src/core/lib/iomgr/timer_manager.cc', |
||||
'src/core/lib/iomgr/timer_uv.cc', |
||||
'src/core/lib/iomgr/udp_server.cc', |
||||
'src/core/lib/iomgr/unix_sockets_posix.cc', |
||||
'src/core/lib/iomgr/unix_sockets_posix_noop.cc', |
||||
'src/core/lib/iomgr/wakeup_fd_cv.cc', |
||||
'src/core/lib/iomgr/wakeup_fd_eventfd.cc', |
||||
'src/core/lib/iomgr/wakeup_fd_nospecial.cc', |
||||
'src/core/lib/iomgr/wakeup_fd_pipe.cc', |
||||
'src/core/lib/iomgr/wakeup_fd_posix.cc', |
||||
'src/core/lib/json/json.cc', |
||||
'src/core/lib/json/json_reader.cc', |
||||
'src/core/lib/json/json_string.cc', |
||||
'src/core/lib/json/json_writer.cc', |
||||
'src/core/lib/slice/b64.cc', |
||||
'src/core/lib/slice/percent_encoding.cc', |
||||
'src/core/lib/slice/slice.cc', |
||||
'src/core/lib/slice/slice_buffer.cc', |
||||
'src/core/lib/slice/slice_hash_table.cc', |
||||
'src/core/lib/slice/slice_intern.cc', |
||||
'src/core/lib/slice/slice_string_helpers.cc', |
||||
'src/core/lib/surface/alarm.cc', |
||||
'src/core/lib/surface/api_trace.cc', |
||||
'src/core/lib/surface/byte_buffer.cc', |
||||
'src/core/lib/surface/byte_buffer_reader.cc', |
||||
'src/core/lib/surface/call.cc', |
||||
'src/core/lib/surface/call_details.cc', |
||||
'src/core/lib/surface/call_log_batch.cc', |
||||
'src/core/lib/surface/channel.cc', |
||||
'src/core/lib/surface/channel_init.cc', |
||||
'src/core/lib/surface/channel_ping.cc', |
||||
'src/core/lib/surface/channel_stack_type.cc', |
||||
'src/core/lib/surface/completion_queue.cc', |
||||
'src/core/lib/surface/completion_queue_factory.cc', |
||||
'src/core/lib/surface/event_string.cc', |
||||
'src/core/lib/surface/lame_client.cc', |
||||
'src/core/lib/surface/metadata_array.cc', |
||||
'src/core/lib/surface/server.cc', |
||||
'src/core/lib/surface/validate_metadata.cc', |
||||
'src/core/lib/surface/version.cc', |
||||
'src/core/lib/transport/bdp_estimator.cc', |
||||
'src/core/lib/transport/byte_stream.cc', |
||||
'src/core/lib/transport/connectivity_state.cc', |
||||
'src/core/lib/transport/error_utils.cc', |
||||
'src/core/lib/transport/metadata.cc', |
||||
'src/core/lib/transport/metadata_batch.cc', |
||||
'src/core/lib/transport/pid_controller.cc', |
||||
'src/core/lib/transport/service_config.cc', |
||||
'src/core/lib/transport/static_metadata.cc', |
||||
'src/core/lib/transport/status_conversion.cc', |
||||
'src/core/lib/transport/timeout_encoding.cc', |
||||
'src/core/lib/transport/transport.cc', |
||||
'src/core/lib/transport/transport_op_string.cc', |
||||
'src/core/lib/debug/trace.cc', |
||||
'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc', |
||||
'src/core/ext/transport/chttp2/transport/bin_decoder.cc', |
||||
'src/core/ext/transport/chttp2/transport/bin_encoder.cc', |
||||
'src/core/ext/transport/chttp2/transport/chttp2_plugin.cc', |
||||
'src/core/ext/transport/chttp2/transport/chttp2_transport.cc', |
||||
'src/core/ext/transport/chttp2/transport/flow_control.cc', |
||||
'src/core/ext/transport/chttp2/transport/frame_data.cc', |
||||
'src/core/ext/transport/chttp2/transport/frame_goaway.cc', |
||||
'src/core/ext/transport/chttp2/transport/frame_ping.cc', |
||||
'src/core/ext/transport/chttp2/transport/frame_rst_stream.cc', |
||||
'src/core/ext/transport/chttp2/transport/frame_settings.cc', |
||||
'src/core/ext/transport/chttp2/transport/frame_window_update.cc', |
||||
'src/core/ext/transport/chttp2/transport/hpack_encoder.cc', |
||||
'src/core/ext/transport/chttp2/transport/hpack_parser.cc', |
||||
'src/core/ext/transport/chttp2/transport/hpack_table.cc', |
||||
'src/core/ext/transport/chttp2/transport/http2_settings.cc', |
||||
'src/core/ext/transport/chttp2/transport/huffsyms.cc', |
||||
'src/core/ext/transport/chttp2/transport/incoming_metadata.cc', |
||||
'src/core/ext/transport/chttp2/transport/parsing.cc', |
||||
'src/core/ext/transport/chttp2/transport/stream_lists.cc', |
||||
'src/core/ext/transport/chttp2/transport/stream_map.cc', |
||||
'src/core/ext/transport/chttp2/transport/varint.cc', |
||||
'src/core/ext/transport/chttp2/transport/writing.cc', |
||||
'src/core/ext/transport/chttp2/alpn/alpn.cc', |
||||
'src/core/ext/filters/http/client/http_client_filter.cc', |
||||
'src/core/ext/filters/http/http_filters_plugin.cc', |
||||
'src/core/ext/filters/http/message_compress/message_compress_filter.cc', |
||||
'src/core/ext/filters/http/server/http_server_filter.cc', |
||||
'src/core/lib/http/httpcli_security_connector.cc', |
||||
'src/core/lib/security/context/security_context.cc', |
||||
'src/core/lib/security/credentials/composite/composite_credentials.cc', |
||||
'src/core/lib/security/credentials/credentials.cc', |
||||
'src/core/lib/security/credentials/credentials_metadata.cc', |
||||
'src/core/lib/security/credentials/fake/fake_credentials.cc', |
||||
'src/core/lib/security/credentials/google_default/credentials_generic.cc', |
||||
'src/core/lib/security/credentials/google_default/google_default_credentials.cc', |
||||
'src/core/lib/security/credentials/iam/iam_credentials.cc', |
||||
'src/core/lib/security/credentials/jwt/json_token.cc', |
||||
'src/core/lib/security/credentials/jwt/jwt_credentials.cc', |
||||
'src/core/lib/security/credentials/jwt/jwt_verifier.cc', |
||||
'src/core/lib/security/credentials/oauth2/oauth2_credentials.cc', |
||||
'src/core/lib/security/credentials/plugin/plugin_credentials.cc', |
||||
'src/core/lib/security/credentials/ssl/ssl_credentials.cc', |
||||
'src/core/lib/security/transport/client_auth_filter.cc', |
||||
'src/core/lib/security/transport/lb_targets_info.cc', |
||||
'src/core/lib/security/transport/secure_endpoint.cc', |
||||
'src/core/lib/security/transport/security_connector.cc', |
||||
'src/core/lib/security/transport/security_handshaker.cc', |
||||
'src/core/lib/security/transport/server_auth_filter.cc', |
||||
'src/core/lib/security/transport/tsi_error.cc', |
||||
'src/core/lib/security/util/json_util.cc', |
||||
'src/core/lib/surface/init_secure.cc', |
||||
'src/core/tsi/fake_transport_security.cc', |
||||
'src/core/tsi/gts_transport_security.cc', |
||||
'src/core/tsi/ssl_transport_security.cc', |
||||
'src/core/tsi/transport_security_grpc.cc', |
||||
'src/core/tsi/transport_security.cc', |
||||
'src/core/tsi/transport_security_adapter.cc', |
||||
'src/core/ext/transport/chttp2/server/chttp2_server.cc', |
||||
'src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc', |
||||
'src/core/ext/filters/client_channel/channel_connectivity.cc', |
||||
'src/core/ext/filters/client_channel/client_channel.cc', |
||||
'src/core/ext/filters/client_channel/client_channel_factory.cc', |
||||
'src/core/ext/filters/client_channel/client_channel_plugin.cc', |
||||
'src/core/ext/filters/client_channel/connector.cc', |
||||
'src/core/ext/filters/client_channel/http_connect_handshaker.cc', |
||||
'src/core/ext/filters/client_channel/http_proxy.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy_factory.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy_registry.cc', |
||||
'src/core/ext/filters/client_channel/parse_address.cc', |
||||
'src/core/ext/filters/client_channel/proxy_mapper.cc', |
||||
'src/core/ext/filters/client_channel/proxy_mapper_registry.cc', |
||||
'src/core/ext/filters/client_channel/resolver.cc', |
||||
'src/core/ext/filters/client_channel/resolver_factory.cc', |
||||
'src/core/ext/filters/client_channel/resolver_registry.cc', |
||||
'src/core/ext/filters/client_channel/retry_throttle.cc', |
||||
'src/core/ext/filters/client_channel/subchannel.cc', |
||||
'src/core/ext/filters/client_channel/subchannel_index.cc', |
||||
'src/core/ext/filters/client_channel/uri_parser.cc', |
||||
'src/core/ext/filters/deadline/deadline_filter.cc', |
||||
'src/core/ext/transport/chttp2/client/chttp2_connector.cc', |
||||
'src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc', |
||||
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc', |
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', |
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', |
||||
'src/core/ext/transport/inproc/inproc_plugin.cc', |
||||
'src/core/ext/transport/inproc/inproc_transport.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', |
||||
'third_party/nanopb/pb_common.c', |
||||
'third_party/nanopb/pb_decode.c', |
||||
'third_party/nanopb/pb_encode.c', |
||||
'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc', |
||||
'src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', |
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', |
||||
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', |
||||
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', |
||||
'src/core/ext/filters/load_reporting/server_load_reporting_filter.cc', |
||||
'src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc', |
||||
'src/core/ext/census/base_resources.cc', |
||||
'src/core/ext/census/context.cc', |
||||
'src/core/ext/census/gen/census.pb.c', |
||||
'src/core/ext/census/gen/trace_context.pb.c', |
||||
'src/core/ext/census/grpc_context.cc', |
||||
'src/core/ext/census/grpc_filter.cc', |
||||
'src/core/ext/census/grpc_plugin.cc', |
||||
'src/core/ext/census/initialize.cc', |
||||
'src/core/ext/census/intrusive_hash_map.cc', |
||||
'src/core/ext/census/mlog.cc', |
||||
'src/core/ext/census/operation.cc', |
||||
'src/core/ext/census/placeholders.cc', |
||||
'src/core/ext/census/resource.cc', |
||||
'src/core/ext/census/trace_context.cc', |
||||
'src/core/ext/census/tracing.cc', |
||||
'src/core/ext/filters/max_age/max_age_filter.cc', |
||||
'src/core/ext/filters/message_size/message_size_filter.cc', |
||||
'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', |
||||
'src/core/ext/filters/workarounds/workaround_utils.cc', |
||||
'src/core/plugin_registry/grpc_plugin_registry.cc', |
||||
], |
||||
'conditions': [ |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
] |
||||
}, |
||||
{ |
||||
'include_dirs': [ |
||||
"<!(node -e \"require('nan')\")" |
||||
], |
||||
'cflags': [ |
||||
'-pthread', |
||||
'-zdefs', |
||||
'-Wno-error=deprecated-declarations' |
||||
], |
||||
"conditions": [ |
||||
['OS=="win" or runtime=="electron"', { |
||||
'dependencies': [ |
||||
"boringssl", |
||||
] |
||||
}], |
||||
['OS=="win"', { |
||||
'dependencies': [ |
||||
"z", |
||||
] |
||||
}], |
||||
['OS=="linux"', { |
||||
'ldflags': [ |
||||
'-Wl,-wrap,memcpy' |
||||
] |
||||
}], |
||||
['OS == "mac"', { |
||||
'xcode_settings': { |
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9' |
||||
} |
||||
}] |
||||
], |
||||
"target_name": "grpc_node", |
||||
"sources": [ |
||||
"src/node/ext/byte_buffer.cc", |
||||
"src/node/ext/call.cc", |
||||
"src/node/ext/call_credentials.cc", |
||||
"src/node/ext/channel.cc", |
||||
"src/node/ext/channel_credentials.cc", |
||||
"src/node/ext/completion_queue.cc", |
||||
"src/node/ext/node_grpc.cc", |
||||
"src/node/ext/server.cc", |
||||
"src/node/ext/server_credentials.cc", |
||||
"src/node/ext/slice.cc", |
||||
"src/node/ext/timeval.cc", |
||||
], |
||||
"dependencies": [ |
||||
"grpc", |
||||
"gpr", |
||||
] |
||||
}, |
||||
{ |
||||
"target_name": "action_after_build", |
||||
"type": "none", |
||||
"dependencies": [ "<(module_name)" ], |
||||
"copies": [ |
||||
{ |
||||
"files": [ "<(PRODUCT_DIR)/<(module_name).node"], |
||||
"destination": "<(module_path)" |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,58 +0,0 @@ |
||||
<?php |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: helloworld.proto |
||||
|
||||
namespace Helloworld; |
||||
|
||||
use Google\Protobuf\Internal\DescriptorPool; |
||||
use Google\Protobuf\Internal\GPBType; |
||||
use Google\Protobuf\Internal\RepeatedField; |
||||
use Google\Protobuf\Internal\GPBUtil; |
||||
|
||||
class HelloRequest extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
private $name = ''; |
||||
|
||||
public function getName() |
||||
{ |
||||
return $this->name; |
||||
} |
||||
|
||||
public function setName($var) |
||||
{ |
||||
GPBUtil::checkString($var, True); |
||||
$this->name = $var; |
||||
} |
||||
|
||||
} |
||||
|
||||
class HelloReply extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
private $message = ''; |
||||
|
||||
public function getMessage() |
||||
{ |
||||
return $this->message; |
||||
} |
||||
|
||||
public function setMessage($var) |
||||
{ |
||||
GPBUtil::checkString($var, True); |
||||
$this->message = $var; |
||||
} |
||||
|
||||
} |
||||
|
||||
$pool = DescriptorPool::getGeneratedPool(); |
||||
|
||||
$pool->internalAddGeneratedFile(hex2bin( |
||||
"0ae6010a1068656c6c6f776f726c642e70726f746f120a68656c6c6f776f" . |
||||
"726c64221c0a0c48656c6c6f52657175657374120c0a046e616d65180120" . |
||||
"012809221d0a0a48656c6c6f5265706c79120f0a076d6573736167651801" . |
||||
"2001280932490a0747726565746572123e0a0853617948656c6c6f12182e" . |
||||
"68656c6c6f776f726c642e48656c6c6f526571756573741a162e68656c6c" . |
||||
"6f776f726c642e48656c6c6f5265706c79220042360a1b696f2e67727063" . |
||||
"2e6578616d706c65732e68656c6c6f776f726c64420f48656c6c6f576f72" . |
||||
"6c6450726f746f5001a20203484c57620670726f746f33" |
||||
)); |
||||
|
@ -1,49 +0,0 @@ |
||||
<?php |
||||
// GENERATED CODE -- DO NOT EDIT! |
||||
|
||||
// Original file comments: |
||||
// 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. |
||||
// |
||||
namespace Helloworld { |
||||
|
||||
// The greeting service definition. |
||||
class GreeterClient extends \Grpc\BaseStub { |
||||
|
||||
/** |
||||
* @param string $hostname hostname |
||||
* @param array $opts channel options |
||||
* @param Grpc\Channel $channel (optional) re-use channel object |
||||
*/ |
||||
public function __construct($hostname, $opts, $channel = null) { |
||||
parent::__construct($hostname, $opts, $channel); |
||||
} |
||||
|
||||
/** |
||||
* Sends a greeting |
||||
* @param \Helloworld\HelloRequest $argument input argument |
||||
* @param array $metadata metadata |
||||
* @param array $options call options |
||||
*/ |
||||
public function SayHello(\Helloworld\HelloRequest $argument, |
||||
$metadata = [], $options = []) { |
||||
return $this->_simpleRequest('/helloworld.Greeter/SayHello', |
||||
$argument, |
||||
['\Helloworld\HelloReply', 'decode'], |
||||
$metadata, $options); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -1,209 +0,0 @@ |
||||
<?php |
||||
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
# source: route_guide.proto |
||||
|
||||
namespace Routeguide; |
||||
|
||||
use Google\Protobuf\Internal\DescriptorPool; |
||||
use Google\Protobuf\Internal\GPBType; |
||||
use Google\Protobuf\Internal\RepeatedField; |
||||
use Google\Protobuf\Internal\GPBUtil; |
||||
|
||||
class Point extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
private $latitude = 0; |
||||
private $longitude = 0; |
||||
|
||||
public function getLatitude() |
||||
{ |
||||
return $this->latitude; |
||||
} |
||||
|
||||
public function setLatitude($var) |
||||
{ |
||||
GPBUtil::checkInt32($var); |
||||
$this->latitude = $var; |
||||
} |
||||
|
||||
public function getLongitude() |
||||
{ |
||||
return $this->longitude; |
||||
} |
||||
|
||||
public function setLongitude($var) |
||||
{ |
||||
GPBUtil::checkInt32($var); |
||||
$this->longitude = $var; |
||||
} |
||||
|
||||
} |
||||
|
||||
class Rectangle extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
private $lo = null; |
||||
private $hi = null; |
||||
|
||||
public function getLo() |
||||
{ |
||||
return $this->lo; |
||||
} |
||||
|
||||
public function setLo(&$var) |
||||
{ |
||||
GPBUtil::checkMessage($var, \Routeguide\Point::class); |
||||
$this->lo = $var; |
||||
} |
||||
|
||||
public function getHi() |
||||
{ |
||||
return $this->hi; |
||||
} |
||||
|
||||
public function setHi(&$var) |
||||
{ |
||||
GPBUtil::checkMessage($var, \Routeguide\Point::class); |
||||
$this->hi = $var; |
||||
} |
||||
|
||||
} |
||||
|
||||
class Feature extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
private $name = ''; |
||||
private $location = null; |
||||
|
||||
public function getName() |
||||
{ |
||||
return $this->name; |
||||
} |
||||
|
||||
public function setName($var) |
||||
{ |
||||
GPBUtil::checkString($var, True); |
||||
$this->name = $var; |
||||
} |
||||
|
||||
public function getLocation() |
||||
{ |
||||
return $this->location; |
||||
} |
||||
|
||||
public function setLocation(&$var) |
||||
{ |
||||
GPBUtil::checkMessage($var, \Routeguide\Point::class); |
||||
$this->location = $var; |
||||
} |
||||
|
||||
} |
||||
|
||||
class RouteNote extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
private $location = null; |
||||
private $message = ''; |
||||
|
||||
public function getLocation() |
||||
{ |
||||
return $this->location; |
||||
} |
||||
|
||||
public function setLocation(&$var) |
||||
{ |
||||
GPBUtil::checkMessage($var, \Routeguide\Point::class); |
||||
$this->location = $var; |
||||
} |
||||
|
||||
public function getMessage() |
||||
{ |
||||
return $this->message; |
||||
} |
||||
|
||||
public function setMessage($var) |
||||
{ |
||||
GPBUtil::checkString($var, True); |
||||
$this->message = $var; |
||||
} |
||||
|
||||
} |
||||
|
||||
class RouteSummary extends \Google\Protobuf\Internal\Message |
||||
{ |
||||
private $point_count = 0; |
||||
private $feature_count = 0; |
||||
private $distance = 0; |
||||
private $elapsed_time = 0; |
||||
|
||||
public function getPointCount() |
||||
{ |
||||
return $this->point_count; |
||||
} |
||||
|
||||
public function setPointCount($var) |
||||
{ |
||||
GPBUtil::checkInt32($var); |
||||
$this->point_count = $var; |
||||
} |
||||
|
||||
public function getFeatureCount() |
||||
{ |
||||
return $this->feature_count; |
||||
} |
||||
|
||||
public function setFeatureCount($var) |
||||
{ |
||||
GPBUtil::checkInt32($var); |
||||
$this->feature_count = $var; |
||||
} |
||||
|
||||
public function getDistance() |
||||
{ |
||||
return $this->distance; |
||||
} |
||||
|
||||
public function setDistance($var) |
||||
{ |
||||
GPBUtil::checkInt32($var); |
||||
$this->distance = $var; |
||||
} |
||||
|
||||
public function getElapsedTime() |
||||
{ |
||||
return $this->elapsed_time; |
||||
} |
||||
|
||||
public function setElapsedTime($var) |
||||
{ |
||||
GPBUtil::checkInt32($var); |
||||
$this->elapsed_time = $var; |
||||
} |
||||
|
||||
} |
||||
|
||||
$pool = DescriptorPool::getGeneratedPool(); |
||||
|
||||
$pool->internalAddGeneratedFile(hex2bin( |
||||
"0ac5050a11726f7574655f67756964652e70726f746f120a726f75746567" . |
||||
"75696465222c0a05506f696e7412100a086c617469747564651801200128" . |
||||
"0512110a096c6f6e67697475646518022001280522490a0952656374616e" . |
||||
"676c65121d0a026c6f18012001280b32112e726f75746567756964652e50" . |
||||
"6f696e74121d0a02686918022001280b32112e726f75746567756964652e" . |
||||
"506f696e74223c0a0746656174757265120c0a046e616d65180120012809" . |
||||
"12230a086c6f636174696f6e18022001280b32112e726f75746567756964" . |
||||
"652e506f696e7422410a09526f7574654e6f746512230a086c6f63617469" . |
||||
"6f6e18012001280b32112e726f75746567756964652e506f696e74120f0a" . |
||||
"076d65737361676518022001280922620a0c526f75746553756d6d617279" . |
||||
"12130a0b706f696e745f636f756e7418012001280512150a0d6665617475" . |
||||
"72655f636f756e7418022001280512100a0864697374616e636518032001" . |
||||
"280512140a0c656c61707365645f74696d651804200128053285020a0a52" . |
||||
"6f757465477569646512360a0a4765744665617475726512112e726f7574" . |
||||
"6567756964652e506f696e741a132e726f75746567756964652e46656174" . |
||||
"7572652200123e0a0c4c697374466561747572657312152e726f75746567" . |
||||
"756964652e52656374616e676c651a132e726f75746567756964652e4665" . |
||||
"617475726522003001123e0a0b5265636f7264526f75746512112e726f75" . |
||||
"746567756964652e506f696e741a182e726f75746567756964652e526f75" . |
||||
"746553756d6d61727922002801123f0a09526f7574654368617412152e72" . |
||||
"6f75746567756964652e526f7574654e6f74651a152e726f757465677569" . |
||||
"64652e526f7574654e6f746522002801300142360a1b696f2e677270632e" . |
||||
"6578616d706c65732e726f7574656775696465420f526f75746547756964" . |
||||
"6550726f746f5001a20203525447620670726f746f33" |
||||
)); |
||||
|
@ -1,101 +0,0 @@ |
||||
<?php |
||||
// GENERATED CODE -- DO NOT EDIT! |
||||
|
||||
// Original file comments: |
||||
// 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. |
||||
// |
||||
namespace Routeguide { |
||||
|
||||
// Interface exported by the server. |
||||
class RouteGuideClient extends \Grpc\BaseStub { |
||||
|
||||
/** |
||||
* @param string $hostname hostname |
||||
* @param array $opts channel options |
||||
* @param Grpc\Channel $channel (optional) re-use channel object |
||||
*/ |
||||
public function __construct($hostname, $opts, $channel = null) { |
||||
parent::__construct($hostname, $opts, $channel); |
||||
} |
||||
|
||||
/** |
||||
* A simple RPC. |
||||
* |
||||
* Obtains the feature at a given position. |
||||
* |
||||
* A feature with an empty name is returned if there's no feature at the given |
||||
* position. |
||||
* @param \Routeguide\Point $argument input argument |
||||
* @param array $metadata metadata |
||||
* @param array $options call options |
||||
*/ |
||||
public function GetFeature(\Routeguide\Point $argument, |
||||
$metadata = [], $options = []) { |
||||
return $this->_simpleRequest('/routeguide.RouteGuide/GetFeature', |
||||
$argument, |
||||
['\Routeguide\Feature', 'decode'], |
||||
$metadata, $options); |
||||
} |
||||
|
||||
/** |
||||
* A server-to-client streaming RPC. |
||||
* |
||||
* Obtains the Features available within the given Rectangle. Results are |
||||
* streamed rather than returned at once (e.g. in a response message with a |
||||
* repeated field), as the rectangle may cover a large area and contain a |
||||
* huge number of features. |
||||
* @param \Routeguide\Rectangle $argument input argument |
||||
* @param array $metadata metadata |
||||
* @param array $options call options |
||||
*/ |
||||
public function ListFeatures(\Routeguide\Rectangle $argument, |
||||
$metadata = [], $options = []) { |
||||
return $this->_serverStreamRequest('/routeguide.RouteGuide/ListFeatures', |
||||
$argument, |
||||
['\Routeguide\Feature', 'decode'], |
||||
$metadata, $options); |
||||
} |
||||
|
||||
/** |
||||
* A client-to-server streaming RPC. |
||||
* |
||||
* Accepts a stream of Points on a route being traversed, returning a |
||||
* RouteSummary when traversal is completed. |
||||
* @param array $metadata metadata |
||||
* @param array $options call options |
||||
*/ |
||||
public function RecordRoute($metadata = [], $options = []) { |
||||
return $this->_clientStreamRequest('/routeguide.RouteGuide/RecordRoute', |
||||
['\Routeguide\RouteSummary','decode'], |
||||
$metadata, $options); |
||||
} |
||||
|
||||
/** |
||||
* A Bidirectional streaming RPC. |
||||
* |
||||
* Accepts a stream of RouteNotes sent while a route is being traversed, |
||||
* while receiving other RouteNotes (e.g. from other users). |
||||
* @param array $metadata metadata |
||||
* @param array $options call options |
||||
*/ |
||||
public function RouteChat($metadata = [], $options = []) { |
||||
return $this->_bidiRequest('/routeguide.RouteGuide/RouteChat', |
||||
['\Routeguide\RouteNote','decode'], |
||||
$metadata, $options); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -1,103 +0,0 @@ |
||||
{ |
||||
"name": "grpc", |
||||
"version": "1.8.0-dev", |
||||
"author": "Google Inc.", |
||||
"description": "gRPC Library for Node", |
||||
"homepage": "https://grpc.io/", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/grpc/grpc.git" |
||||
}, |
||||
"bugs": "https://github.com/grpc/grpc/issues", |
||||
"contributors": [ |
||||
{ |
||||
"name": "Michael Lumish", |
||||
"email": "mlumish@google.com" |
||||
} |
||||
], |
||||
"directories": { |
||||
"lib": "src/node/src" |
||||
}, |
||||
"scripts": { |
||||
"lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore", |
||||
"test": "./node_modules/.bin/mocha src/node/test && npm run-script lint", |
||||
"electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell", |
||||
"gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json", |
||||
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test", |
||||
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build --library=static_library" |
||||
}, |
||||
"bundledDependencies": [ |
||||
"node-pre-gyp" |
||||
], |
||||
"dependencies": { |
||||
"arguejs": "^0.2.3", |
||||
"lodash": "^4.15.0", |
||||
"nan": "^2.0.0", |
||||
"node-pre-gyp": "^0.6.35", |
||||
"protobufjs": "^5.0.0" |
||||
}, |
||||
"devDependencies": { |
||||
"async": "^2.0.1", |
||||
"body-parser": "^1.15.2", |
||||
"electron-mocha": "^3.1.1", |
||||
"express": "^4.14.0", |
||||
"google-auth-library": "^0.9.2", |
||||
"google-protobuf": "^3.0.0", |
||||
"istanbul": "^0.4.4", |
||||
"jsdoc": "^3.3.2", |
||||
"jshint": "^2.5.0", |
||||
"minimist": "^1.1.0", |
||||
"mocha": "^3.0.2", |
||||
"mocha-jenkins-reporter": "^0.2.3", |
||||
"poisson-process": "^0.2.1" |
||||
}, |
||||
"engines": { |
||||
"node": ">=4" |
||||
}, |
||||
"binary": { |
||||
"module_name": "grpc_node", |
||||
"module_path": "src/node/extension_binary/{node_abi}-{platform}-{arch}", |
||||
"host": "https://storage.googleapis.com/", |
||||
"remote_path": "grpc-precompiled-binaries/node/{name}/v{version}", |
||||
"package_name": "{node_abi}-{platform}-{arch}.tar.gz" |
||||
}, |
||||
"files": [ |
||||
"LICENSE", |
||||
"src/node/README.md", |
||||
"src/proto", |
||||
"etc", |
||||
"src/node/index.js", |
||||
"src/node/src", |
||||
"src/node/ext", |
||||
"include/grpc", |
||||
"src/core", |
||||
"src/boringssl", |
||||
"src/zlib", |
||||
"third_party/nanopb", |
||||
"third_party/zlib", |
||||
"third_party/boringssl", |
||||
"binding.gyp" |
||||
], |
||||
"main": "src/node/index.js", |
||||
"license": "Apache-2.0", |
||||
"jshintConfig": { |
||||
"bitwise": true, |
||||
"curly": true, |
||||
"eqeqeq": true, |
||||
"esnext": true, |
||||
"freeze": true, |
||||
"immed": true, |
||||
"indent": 2, |
||||
"latedef": "nofunc", |
||||
"maxlen": 80, |
||||
"mocha": true, |
||||
"newcap": true, |
||||
"node": true, |
||||
"noarg": true, |
||||
"quotmark": "single", |
||||
"strict": true, |
||||
"trailing": true, |
||||
"undef": true, |
||||
"unused": "vars" |
||||
} |
||||
} |
@ -1,61 +0,0 @@ |
||||
<!--- |
||||
* 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. |
||||
--> |
||||
|
||||
# Census - a resource measurement and tracing system |
||||
|
||||
This directory contains code for Census, which will ultimately provide the |
||||
following features for any gRPC-using system: |
||||
* A [dapper](http://research.google.com/pubs/pub36356.html)-like tracing |
||||
system, enabling tracing across a distributed infrastructure. |
||||
* RPC statistics and measurements for key metrics, such as latency, bytes |
||||
transferred, number of errors etc. |
||||
* Resource measurement framework which can be used for measuring custom |
||||
metrics. Through the use of [tags](#Tags), these can be broken down across |
||||
the entire distributed stack. |
||||
* Easy integration of the above with |
||||
[Google Cloud Trace](https://cloud.google.com/tools/cloud-trace) and |
||||
[Google Cloud Monitoring](https://cloud.google.com/monitoring/). |
||||
|
||||
## Concepts |
||||
|
||||
### Context |
||||
|
||||
### Operations |
||||
|
||||
### Tags |
||||
|
||||
### Metrics |
||||
|
||||
## API |
||||
|
||||
### Internal/RPC API |
||||
|
||||
### External/Client API |
||||
|
||||
### RPC API |
||||
|
||||
## Files in this directory |
||||
|
||||
Note that files and functions in this directory can be split into two |
||||
categories: |
||||
* Files that define core census library functions. Functions etc. in these |
||||
files are named census\_\*, and constitute the core census library |
||||
functionality. At some time in the future, these will become a standalone |
||||
library. |
||||
* Files that define functions etc. that provide a convenient interface between |
||||
grpc and the core census functionality. These files are all named |
||||
grpc\_\*.{c,h}, and define function names beginning with grpc\_census\_\*. |
||||
|
@ -1,51 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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 */ |
@ -1,56 +0,0 @@ |
||||
/*
|
||||
* Copyright 2016 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 "src/core/ext/census/base_resources.h" |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/census.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/ext/census/resource.h" |
||||
|
||||
// Add base RPC resource definitions for use by RPC runtime.
|
||||
//
|
||||
// TODO(aveitch): All of these are currently hardwired definitions encoded in
|
||||
// the code in this file. These should be converted to use an external
|
||||
// configuration mechanism, in which these resources are defined in a text
|
||||
// file, which is compiled to .pb format and read by still-to-be-written
|
||||
// configuration functions.
|
||||
|
||||
// Define all base resources. This should be called by census initialization.
|
||||
void define_base_resources() { |
||||
google_census_Resource_BasicUnit numerator = |
||||
google_census_Resource_BasicUnit_SECS; |
||||
resource r = {(char *)"client_rpc_latency", // name
|
||||
(char *)"Client RPC latency in seconds", // description
|
||||
0, // prefix
|
||||
1, // n_numerators
|
||||
&numerator, // numerators
|
||||
0, // n_denominators
|
||||
NULL}; // denominators
|
||||
define_resource(&r); |
||||
r = {(char *)"server_rpc_latency", // name
|
||||
(char *)"Server RPC latency in seconds", // description
|
||||
0, // prefix
|
||||
1, // n_numerators
|
||||
&numerator, // numerators
|
||||
0, // n_denominators
|
||||
NULL}; // denominators
|
||||
define_resource(&r); |
||||
} |
@ -1,32 +0,0 @@ |
||||
/*
|
||||
* Copyright 2016 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. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H |
||||
#define GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Define all base resources. This should be called by census initialization. */ |
||||
void define_base_resources(); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */ |
@ -1,33 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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 "src/core/ext/census/census_interface.h" |
||||
|
||||
#include <grpc/support/log.h> |
||||
#include "src/core/ext/census/census_rpc_stats.h" |
||||
#include "src/core/ext/census/census_tracing.h" |
||||
|
||||
void census_init(void) { |
||||
census_tracing_init(); |
||||
census_stats_store_init(); |
||||
} |
||||
|
||||
void census_shutdown(void) { |
||||
census_stats_store_shutdown(); |
||||
census_tracing_shutdown(); |
||||
} |
@ -1,69 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H |
||||
#define GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
/* Maximum length of an individual census trace annotation. */ |
||||
#define CENSUS_MAX_ANNOTATION_LENGTH 200 |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Structure of a census op id. Define as structure because 64bit integer is not
|
||||
available on every platform for C89. */ |
||||
typedef struct census_op_id { |
||||
uint32_t upper; |
||||
uint32_t lower; |
||||
} census_op_id; |
||||
|
||||
typedef struct census_rpc_stats census_rpc_stats; |
||||
|
||||
/* Initializes Census library. No-op if Census is already initialized. */ |
||||
void census_init(void); |
||||
|
||||
/* Shutdown Census Library. */ |
||||
void census_shutdown(void); |
||||
|
||||
/* Annotates grpc method name on a census_op_id. The method name has the format
|
||||
of <full quantified rpc service name>/<rpc function name>. Returns 0 iff |
||||
op_id and method_name are all valid. op_id is valid after its creation and |
||||
before calling census_tracing_end_op(). |
||||
|
||||
TODO(hongyu): Figure out valid characters set for service name and command |
||||
name and document requirements here.*/ |
||||
int census_add_method_tag(census_op_id op_id, const char *method_name); |
||||
|
||||
/* Annotates tracing information to a specific op_id.
|
||||
Up to CENSUS_MAX_ANNOTATION_LENGTH bytes are recorded. */ |
||||
void census_tracing_print(census_op_id op_id, const char *annotation); |
||||
|
||||
/* Starts tracing for an RPC. Returns a locally unique census_op_id */ |
||||
census_op_id census_tracing_start_op(void); |
||||
|
||||
/* Ends tracing. Calling this function will invalidate the input op_id. */ |
||||
void census_tracing_end_op(census_op_id op_id); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H */ |
@ -1,588 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
/* Available log space is divided up in blocks of
|
||||
CENSUS_LOG_2_MAX_RECORD_SIZE bytes. A block can be in one of the |
||||
following three data structures: |
||||
- Free blocks (free_block_list) |
||||
- Blocks with unread data (dirty_block_list) |
||||
- Blocks currently attached to cores (core_local_blocks[]) |
||||
|
||||
census_log_start_write() moves a block from core_local_blocks[] to the |
||||
end of dirty_block_list when block: |
||||
- is out-of-space OR |
||||
- has an incomplete record (an incomplete record occurs when a thread calls |
||||
census_log_start_write() and is context-switched before calling |
||||
census_log_end_write() |
||||
So, blocks in dirty_block_list are ordered, from oldest to newest, by time |
||||
when block is detached from the core. |
||||
|
||||
census_log_read_next() first iterates over dirty_block_list and then |
||||
core_local_blocks[]. It moves completely read blocks from dirty_block_list |
||||
to free_block_list. Blocks in core_local_blocks[] are not freed, even when |
||||
completely read. |
||||
|
||||
If log is configured to discard old records and free_block_list is empty, |
||||
census_log_start_write() iterates over dirty_block_list to allocate a |
||||
new block. It moves the oldest available block (no pending read/write) to |
||||
core_local_blocks[]. |
||||
|
||||
core_local_block_struct is used to implement a map from core id to the block |
||||
associated with that core. This mapping is advisory. It is possible that the |
||||
block returned by this mapping is no longer associated with that core. This |
||||
mapping is updated, lazily, by census_log_start_write(). |
||||
|
||||
Locking in block struct: |
||||
|
||||
Exclusive g_log.lock must be held before calling any functions operatong on |
||||
block structs except census_log_start_write() and |
||||
census_log_end_write(). |
||||
|
||||
Writes to a block are serialized via writer_lock. |
||||
census_log_start_write() acquires this lock and |
||||
census_log_end_write() releases it. On failure to acquire the lock, |
||||
writer allocates a new block for the current core and updates |
||||
core_local_block accordingly. |
||||
|
||||
Simultaneous read and write access is allowed. Reader can safely read up to |
||||
committed bytes (bytes_committed). |
||||
|
||||
reader_lock protects the block, currently being read, from getting recycled. |
||||
start_read() acquires reader_lock and end_read() releases the lock. |
||||
|
||||
Read/write access to a block is disabled via try_disable_access(). It returns |
||||
with both writer_lock and reader_lock held. These locks are subsequently |
||||
released by enable_access() to enable access to the block. |
||||
|
||||
A note on naming: Most function/struct names are prepended by cl_ |
||||
(shorthand for census_log). Further, functions that manipulate structures |
||||
include the name of the structure, which will be passed as the first |
||||
argument. E.g. cl_block_initialize() will initialize a cl_block. |
||||
*/ |
||||
#include "src/core/ext/census/census_log.h" |
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/atm.h> |
||||
#include <grpc/support/cpu.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/port_platform.h> |
||||
#include <grpc/support/sync.h> |
||||
#include <grpc/support/useful.h> |
||||
#include <string.h> |
||||
|
||||
/* End of platform specific code */ |
||||
|
||||
typedef struct census_log_block_list_struct { |
||||
struct census_log_block_list_struct *next; |
||||
struct census_log_block_list_struct *prev; |
||||
struct census_log_block *block; |
||||
} cl_block_list_struct; |
||||
|
||||
typedef struct census_log_block { |
||||
/* Pointer to underlying buffer */ |
||||
char *buffer; |
||||
gpr_atm writer_lock; |
||||
gpr_atm reader_lock; |
||||
/* Keeps completely written bytes. Declared atomic because accessed
|
||||
simultaneously by reader and writer. */ |
||||
gpr_atm bytes_committed; |
||||
/* Bytes already read */ |
||||
int32_t bytes_read; |
||||
/* Links for list */ |
||||
cl_block_list_struct link; |
||||
/* We want this structure to be cacheline aligned. We assume the following
|
||||
sizes for the various parts on 32/64bit systems: |
||||
type 32b size 64b size |
||||
char* 4 8 |
||||
3x gpr_atm 12 24 |
||||
int32_t 4 8 (assumes padding) |
||||
cl_block_list_struct 12 24 |
||||
TOTAL 32 64 |
||||
|
||||
Depending on the size of our cacheline and the architecture, we |
||||
selectively add char buffering to this structure. The size is checked |
||||
via assert in census_log_initialize(). */ |
||||
#if defined(GPR_ARCH_64) |
||||
#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 64) |
||||
#else |
||||
#if defined(GPR_ARCH_32) |
||||
#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 32) |
||||
#else |
||||
#error "Unknown architecture" |
||||
#endif |
||||
#endif |
||||
#if CL_BLOCK_PAD_SIZE > 0 |
||||
char padding[CL_BLOCK_PAD_SIZE]; |
||||
#endif |
||||
} cl_block; |
||||
|
||||
/* A list of cl_blocks, doubly-linked through cl_block::link. */ |
||||
typedef struct census_log_block_list { |
||||
int32_t count; /* Number of items in list. */ |
||||
cl_block_list_struct ht; /* head/tail of linked list. */ |
||||
} cl_block_list; |
||||
|
||||
/* Cacheline aligned block pointers to avoid false sharing. Block pointer must
|
||||
be initialized via set_block(), before calling other functions */ |
||||
typedef struct census_log_core_local_block { |
||||
gpr_atm block; |
||||
/* Ensure cachline alignment: we assume sizeof(gpr_atm) == 4 or 8 */ |
||||
#if defined(GPR_ARCH_64) |
||||
#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 8) |
||||
#else |
||||
#if defined(GPR_ARCH_32) |
||||
#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 4) |
||||
#else |
||||
#error "Unknown architecture" |
||||
#endif |
||||
#endif |
||||
#if CL_CORE_LOCAL_BLOCK_PAD_SIZE > 0 |
||||
char padding[CL_CORE_LOCAL_BLOCK_PAD_SIZE]; |
||||
#endif |
||||
} cl_core_local_block; |
||||
|
||||
struct census_log { |
||||
int discard_old_records; |
||||
/* Number of cores (aka hardware-contexts) */ |
||||
unsigned num_cores; |
||||
/* number of CENSUS_LOG_2_MAX_RECORD_SIZE blocks in log */ |
||||
int32_t num_blocks; |
||||
cl_block *blocks; /* Block metadata. */ |
||||
cl_core_local_block *core_local_blocks; /* Keeps core to block mappings. */ |
||||
gpr_mu lock; |
||||
int initialized; /* has log been initialized? */ |
||||
/* Keeps the state of the reader iterator. A value of 0 indicates that
|
||||
iterator has reached the end. census_log_init_reader() resets the |
||||
value to num_core to restart iteration. */ |
||||
uint32_t read_iterator_state; |
||||
/* Points to the block being read. If non-NULL, the block is locked for
|
||||
reading (block_being_read_->reader_lock is held). */ |
||||
cl_block *block_being_read; |
||||
/* A non-zero value indicates that log is full. */ |
||||
gpr_atm is_full; |
||||
char *buffer; |
||||
cl_block_list free_block_list; |
||||
cl_block_list dirty_block_list; |
||||
gpr_atm out_of_space_count; |
||||
}; |
||||
|
||||
/* Single internal log */ |
||||
static struct census_log g_log; |
||||
|
||||
/* Functions that operate on an atomic memory location used as a lock */ |
||||
|
||||
/* Returns non-zero if lock is acquired */ |
||||
static int cl_try_lock(gpr_atm *lock) { return gpr_atm_acq_cas(lock, 0, 1); } |
||||
|
||||
static void cl_unlock(gpr_atm *lock) { gpr_atm_rel_store(lock, 0); } |
||||
|
||||
/* Functions that operate on cl_core_local_block's */ |
||||
|
||||
static void cl_core_local_block_set_block(cl_core_local_block *clb, |
||||
cl_block *block) { |
||||
gpr_atm_rel_store(&clb->block, (gpr_atm)block); |
||||
} |
||||
|
||||
static cl_block *cl_core_local_block_get_block(cl_core_local_block *clb) { |
||||
return (cl_block *)gpr_atm_acq_load(&clb->block); |
||||
} |
||||
|
||||
/* Functions that operate on cl_block_list_struct's */ |
||||
|
||||
static void cl_block_list_struct_initialize(cl_block_list_struct *bls, |
||||
cl_block *block) { |
||||
bls->next = bls->prev = bls; |
||||
bls->block = block; |
||||
} |
||||
|
||||
/* Functions that operate on cl_block_list's */ |
||||
|
||||
static void cl_block_list_initialize(cl_block_list *list) { |
||||
list->count = 0; |
||||
cl_block_list_struct_initialize(&list->ht, NULL); |
||||
} |
||||
|
||||
/* Returns head of *this, or NULL if empty. */ |
||||
static cl_block *cl_block_list_head(cl_block_list *list) { |
||||
return list->ht.next->block; |
||||
} |
||||
|
||||
/* Insert element *e after *pos. */ |
||||
static void cl_block_list_insert(cl_block_list *list, cl_block_list_struct *pos, |
||||
cl_block_list_struct *e) { |
||||
list->count++; |
||||
e->next = pos->next; |
||||
e->prev = pos; |
||||
e->next->prev = e; |
||||
e->prev->next = e; |
||||
} |
||||
|
||||
/* Insert block at the head of the list */ |
||||
static void cl_block_list_insert_at_head(cl_block_list *list, cl_block *block) { |
||||
cl_block_list_insert(list, &list->ht, &block->link); |
||||
} |
||||
|
||||
/* Insert block at the tail of the list */ |
||||
static void cl_block_list_insert_at_tail(cl_block_list *list, cl_block *block) { |
||||
cl_block_list_insert(list, list->ht.prev, &block->link); |
||||
} |
||||
|
||||
/* Removes block *b. Requires *b be in the list. */ |
||||
static void cl_block_list_remove(cl_block_list *list, cl_block *b) { |
||||
list->count--; |
||||
b->link.next->prev = b->link.prev; |
||||
b->link.prev->next = b->link.next; |
||||
} |
||||
|
||||
/* Functions that operate on cl_block's */ |
||||
|
||||
static void cl_block_initialize(cl_block *block, char *buffer) { |
||||
block->buffer = buffer; |
||||
gpr_atm_rel_store(&block->writer_lock, 0); |
||||
gpr_atm_rel_store(&block->reader_lock, 0); |
||||
gpr_atm_rel_store(&block->bytes_committed, 0); |
||||
block->bytes_read = 0; |
||||
cl_block_list_struct_initialize(&block->link, block); |
||||
} |
||||
|
||||
/* Guards against exposing partially written buffer to the reader. */ |
||||
static void cl_block_set_bytes_committed(cl_block *block, |
||||
int32_t bytes_committed) { |
||||
gpr_atm_rel_store(&block->bytes_committed, bytes_committed); |
||||
} |
||||
|
||||
static int32_t cl_block_get_bytes_committed(cl_block *block) { |
||||
return gpr_atm_acq_load(&block->bytes_committed); |
||||
} |
||||
|
||||
/* Tries to disable future read/write access to this block. Succeeds if:
|
||||
- no in-progress write AND |
||||
- no in-progress read AND |
||||
- 'discard_data' set to true OR no unread data |
||||
On success, clears the block state and returns with writer_lock_ and |
||||
reader_lock_ held. These locks are released by a subsequent |
||||
cl_block_access_enable() call. */ |
||||
static int cl_block_try_disable_access(cl_block *block, int discard_data) { |
||||
if (!cl_try_lock(&block->writer_lock)) { |
||||
return 0; |
||||
} |
||||
if (!cl_try_lock(&block->reader_lock)) { |
||||
cl_unlock(&block->writer_lock); |
||||
return 0; |
||||
} |
||||
if (!discard_data && |
||||
(block->bytes_read != cl_block_get_bytes_committed(block))) { |
||||
cl_unlock(&block->reader_lock); |
||||
cl_unlock(&block->writer_lock); |
||||
return 0; |
||||
} |
||||
cl_block_set_bytes_committed(block, 0); |
||||
block->bytes_read = 0; |
||||
return 1; |
||||
} |
||||
|
||||
static void cl_block_enable_access(cl_block *block) { |
||||
cl_unlock(&block->reader_lock); |
||||
cl_unlock(&block->writer_lock); |
||||
} |
||||
|
||||
/* Returns with writer_lock held. */ |
||||
static void *cl_block_start_write(cl_block *block, size_t size) { |
||||
int32_t bytes_committed; |
||||
if (!cl_try_lock(&block->writer_lock)) { |
||||
return NULL; |
||||
} |
||||
bytes_committed = cl_block_get_bytes_committed(block); |
||||
if (bytes_committed + size > CENSUS_LOG_MAX_RECORD_SIZE) { |
||||
cl_unlock(&block->writer_lock); |
||||
return NULL; |
||||
} |
||||
return block->buffer + bytes_committed; |
||||
} |
||||
|
||||
/* Releases writer_lock and increments committed bytes by 'bytes_written'.
|
||||
'bytes_written' must be <= 'size' specified in the corresponding |
||||
StartWrite() call. This function is thread-safe. */ |
||||
static void cl_block_end_write(cl_block *block, size_t bytes_written) { |
||||
cl_block_set_bytes_committed( |
||||
block, cl_block_get_bytes_committed(block) + bytes_written); |
||||
cl_unlock(&block->writer_lock); |
||||
} |
||||
|
||||
/* Returns a pointer to the first unread byte in buffer. The number of bytes
|
||||
available are returned in 'bytes_available'. Acquires reader lock that is |
||||
released by a subsequent cl_block_end_read() call. Returns NULL if: |
||||
- read in progress |
||||
- no data available */ |
||||
static void *cl_block_start_read(cl_block *block, size_t *bytes_available) { |
||||
void *record; |
||||
if (!cl_try_lock(&block->reader_lock)) { |
||||
return NULL; |
||||
} |
||||
/* bytes_committed may change from under us. Use bytes_available to update
|
||||
bytes_read below. */ |
||||
*bytes_available = cl_block_get_bytes_committed(block) - block->bytes_read; |
||||
if (*bytes_available == 0) { |
||||
cl_unlock(&block->reader_lock); |
||||
return NULL; |
||||
} |
||||
record = block->buffer + block->bytes_read; |
||||
block->bytes_read += *bytes_available; |
||||
return record; |
||||
} |
||||
|
||||
static void cl_block_end_read(cl_block *block) { |
||||
cl_unlock(&block->reader_lock); |
||||
} |
||||
|
||||
/* Internal functions operating on g_log */ |
||||
|
||||
/* Allocates a new free block (or recycles an available dirty block if log is
|
||||
configured to discard old records). Returns NULL if out-of-space. */ |
||||
static cl_block *cl_allocate_block(void) { |
||||
cl_block *block = cl_block_list_head(&g_log.free_block_list); |
||||
if (block != NULL) { |
||||
cl_block_list_remove(&g_log.free_block_list, block); |
||||
return block; |
||||
} |
||||
if (!g_log.discard_old_records) { |
||||
/* No free block and log is configured to keep old records. */ |
||||
return NULL; |
||||
} |
||||
/* Recycle dirty block. Start from the oldest. */ |
||||
for (block = cl_block_list_head(&g_log.dirty_block_list); block != NULL; |
||||
block = block->link.next->block) { |
||||
if (cl_block_try_disable_access(block, 1 /* discard data */)) { |
||||
cl_block_list_remove(&g_log.dirty_block_list, block); |
||||
return block; |
||||
} |
||||
} |
||||
return NULL; |
||||
} |
||||
|
||||
/* Allocates a new block and updates core id => block mapping. 'old_block'
|
||||
points to the block that the caller thinks is attached to |
||||
'core_id'. 'old_block' may be NULL. Returns non-zero if: |
||||
- allocated a new block OR |
||||
- 'core_id' => 'old_block' mapping changed (another thread allocated a |
||||
block before lock was acquired). */ |
||||
static int cl_allocate_core_local_block(int32_t core_id, cl_block *old_block) { |
||||
/* Now that we have the lock, check if core-local mapping has changed. */ |
||||
cl_core_local_block *core_local_block = &g_log.core_local_blocks[core_id]; |
||||
cl_block *block = cl_core_local_block_get_block(core_local_block); |
||||
if ((block != NULL) && (block != old_block)) { |
||||
return 1; |
||||
} |
||||
if (block != NULL) { |
||||
cl_core_local_block_set_block(core_local_block, NULL); |
||||
cl_block_list_insert_at_tail(&g_log.dirty_block_list, block); |
||||
} |
||||
block = cl_allocate_block(); |
||||
if (block == NULL) { |
||||
gpr_atm_rel_store(&g_log.is_full, 1); |
||||
return 0; |
||||
} |
||||
cl_core_local_block_set_block(core_local_block, block); |
||||
cl_block_enable_access(block); |
||||
return 1; |
||||
} |
||||
|
||||
static cl_block *cl_get_block(void *record) { |
||||
uintptr_t p = (uintptr_t)((char *)record - g_log.buffer); |
||||
uintptr_t index = p >> CENSUS_LOG_2_MAX_RECORD_SIZE; |
||||
return &g_log.blocks[index]; |
||||
} |
||||
|
||||
/* Gets the next block to read and tries to free 'prev' block (if not NULL).
|
||||
Returns NULL if reached the end. */ |
||||
static cl_block *cl_next_block_to_read(cl_block *prev) { |
||||
cl_block *block = NULL; |
||||
if (g_log.read_iterator_state == g_log.num_cores) { |
||||
/* We are traversing dirty list; find the next dirty block. */ |
||||
if (prev != NULL) { |
||||
/* Try to free the previous block if there is no unread data. This block
|
||||
may have unread data if previously incomplete record completed between |
||||
read_next() calls. */ |
||||
block = prev->link.next->block; |
||||
if (cl_block_try_disable_access(prev, 0 /* do not discard data */)) { |
||||
cl_block_list_remove(&g_log.dirty_block_list, prev); |
||||
cl_block_list_insert_at_head(&g_log.free_block_list, prev); |
||||
gpr_atm_rel_store(&g_log.is_full, 0); |
||||
} |
||||
} else { |
||||
block = cl_block_list_head(&g_log.dirty_block_list); |
||||
} |
||||
if (block != NULL) { |
||||
return block; |
||||
} |
||||
/* We are done with the dirty list; moving on to core-local blocks. */ |
||||
} |
||||
while (g_log.read_iterator_state > 0) { |
||||
g_log.read_iterator_state--; |
||||
block = cl_core_local_block_get_block( |
||||
&g_log.core_local_blocks[g_log.read_iterator_state]); |
||||
if (block != NULL) { |
||||
return block; |
||||
} |
||||
} |
||||
return NULL; |
||||
} |
||||
|
||||
/* External functions: primary stats_log interface */ |
||||
void census_log_initialize(size_t size_in_mb, int discard_old_records) { |
||||
int32_t ix; |
||||
/* Check cacheline alignment. */ |
||||
GPR_ASSERT(sizeof(cl_block) % GPR_CACHELINE_SIZE == 0); |
||||
GPR_ASSERT(sizeof(cl_core_local_block) % GPR_CACHELINE_SIZE == 0); |
||||
GPR_ASSERT(!g_log.initialized); |
||||
g_log.discard_old_records = discard_old_records; |
||||
g_log.num_cores = gpr_cpu_num_cores(); |
||||
/* Ensure at least as many blocks as there are cores. */ |
||||
g_log.num_blocks = GPR_MAX( |
||||
g_log.num_cores, (size_in_mb << 20) >> CENSUS_LOG_2_MAX_RECORD_SIZE); |
||||
gpr_mu_init(&g_log.lock); |
||||
g_log.read_iterator_state = 0; |
||||
g_log.block_being_read = NULL; |
||||
gpr_atm_rel_store(&g_log.is_full, 0); |
||||
g_log.core_local_blocks = (cl_core_local_block *)gpr_malloc_aligned( |
||||
g_log.num_cores * sizeof(cl_core_local_block), GPR_CACHELINE_SIZE_LOG); |
||||
memset(g_log.core_local_blocks, 0, |
||||
g_log.num_cores * sizeof(cl_core_local_block)); |
||||
g_log.blocks = (cl_block *)gpr_malloc_aligned( |
||||
g_log.num_blocks * sizeof(cl_block), GPR_CACHELINE_SIZE_LOG); |
||||
memset(g_log.blocks, 0, g_log.num_blocks * sizeof(cl_block)); |
||||
g_log.buffer = gpr_malloc(g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE); |
||||
memset(g_log.buffer, 0, g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE); |
||||
cl_block_list_initialize(&g_log.free_block_list); |
||||
cl_block_list_initialize(&g_log.dirty_block_list); |
||||
for (ix = 0; ix < g_log.num_blocks; ++ix) { |
||||
cl_block *block = g_log.blocks + ix; |
||||
cl_block_initialize(block, |
||||
g_log.buffer + (CENSUS_LOG_MAX_RECORD_SIZE * ix)); |
||||
cl_block_try_disable_access(block, 1 /* discard data */); |
||||
cl_block_list_insert_at_tail(&g_log.free_block_list, block); |
||||
} |
||||
gpr_atm_rel_store(&g_log.out_of_space_count, 0); |
||||
g_log.initialized = 1; |
||||
} |
||||
|
||||
void census_log_shutdown(void) { |
||||
GPR_ASSERT(g_log.initialized); |
||||
gpr_mu_destroy(&g_log.lock); |
||||
gpr_free_aligned(g_log.core_local_blocks); |
||||
g_log.core_local_blocks = NULL; |
||||
gpr_free_aligned(g_log.blocks); |
||||
g_log.blocks = NULL; |
||||
gpr_free(g_log.buffer); |
||||
g_log.buffer = NULL; |
||||
g_log.initialized = 0; |
||||
} |
||||
|
||||
void *census_log_start_write(size_t size) { |
||||
/* Used to bound number of times block allocation is attempted. */ |
||||
int32_t attempts_remaining = g_log.num_blocks; |
||||
/* TODO(aveitch): move this inside the do loop when current_cpu is fixed */ |
||||
int32_t core_id = gpr_cpu_current_cpu(); |
||||
GPR_ASSERT(g_log.initialized); |
||||
if (size > CENSUS_LOG_MAX_RECORD_SIZE) { |
||||
return NULL; |
||||
} |
||||
do { |
||||
int allocated; |
||||
void *record = NULL; |
||||
cl_block *block = |
||||
cl_core_local_block_get_block(&g_log.core_local_blocks[core_id]); |
||||
if (block && (record = cl_block_start_write(block, size))) { |
||||
return record; |
||||
} |
||||
/* Need to allocate a new block. We are here if:
|
||||
- No block associated with the core OR |
||||
- Write in-progress on the block OR |
||||
- block is out of space */ |
||||
if (gpr_atm_acq_load(&g_log.is_full)) { |
||||
gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1); |
||||
return NULL; |
||||
} |
||||
gpr_mu_lock(&g_log.lock); |
||||
allocated = cl_allocate_core_local_block(core_id, block); |
||||
gpr_mu_unlock(&g_log.lock); |
||||
if (!allocated) { |
||||
gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1); |
||||
return NULL; |
||||
} |
||||
} while (attempts_remaining--); |
||||
/* Give up. */ |
||||
gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1); |
||||
return NULL; |
||||
} |
||||
|
||||
void census_log_end_write(void *record, size_t bytes_written) { |
||||
GPR_ASSERT(g_log.initialized); |
||||
cl_block_end_write(cl_get_block(record), bytes_written); |
||||
} |
||||
|
||||
void census_log_init_reader(void) { |
||||
GPR_ASSERT(g_log.initialized); |
||||
gpr_mu_lock(&g_log.lock); |
||||
/* If a block is locked for reading unlock it. */ |
||||
if (g_log.block_being_read != NULL) { |
||||
cl_block_end_read(g_log.block_being_read); |
||||
g_log.block_being_read = NULL; |
||||
} |
||||
g_log.read_iterator_state = g_log.num_cores; |
||||
gpr_mu_unlock(&g_log.lock); |
||||
} |
||||
|
||||
const void *census_log_read_next(size_t *bytes_available) { |
||||
GPR_ASSERT(g_log.initialized); |
||||
gpr_mu_lock(&g_log.lock); |
||||
if (g_log.block_being_read != NULL) { |
||||
cl_block_end_read(g_log.block_being_read); |
||||
} |
||||
do { |
||||
g_log.block_being_read = cl_next_block_to_read(g_log.block_being_read); |
||||
if (g_log.block_being_read != NULL) { |
||||
void *record = |
||||
cl_block_start_read(g_log.block_being_read, bytes_available); |
||||
if (record != NULL) { |
||||
gpr_mu_unlock(&g_log.lock); |
||||
return record; |
||||
} |
||||
} |
||||
} while (g_log.block_being_read != NULL); |
||||
gpr_mu_unlock(&g_log.lock); |
||||
return NULL; |
||||
} |
||||
|
||||
size_t census_log_remaining_space(void) { |
||||
size_t space; |
||||
GPR_ASSERT(g_log.initialized); |
||||
gpr_mu_lock(&g_log.lock); |
||||
if (g_log.discard_old_records) { |
||||
/* Remaining space is not meaningful; just return the entire log space. */ |
||||
space = g_log.num_blocks << CENSUS_LOG_2_MAX_RECORD_SIZE; |
||||
} else { |
||||
space = g_log.free_block_list.count * CENSUS_LOG_MAX_RECORD_SIZE; |
||||
} |
||||
gpr_mu_unlock(&g_log.lock); |
||||
return space; |
||||
} |
||||
|
||||
int census_log_out_of_space_count(void) { |
||||
GPR_ASSERT(g_log.initialized); |
||||
return gpr_atm_acq_load(&g_log.out_of_space_count); |
||||
} |
@ -1,84 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H |
||||
#define GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H |
||||
|
||||
#include <stddef.h> |
||||
|
||||
/* Maximum record size, in bytes. */ |
||||
#define CENSUS_LOG_2_MAX_RECORD_SIZE 14 /* 2^14 = 16KB */ |
||||
#define CENSUS_LOG_MAX_RECORD_SIZE (1 << CENSUS_LOG_2_MAX_RECORD_SIZE) |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Initialize the statistics logging subsystem with the given log size. A log
|
||||
size of 0 will result in the smallest possible log for the platform |
||||
(approximately CENSUS_LOG_MAX_RECORD_SIZE * gpr_cpu_num_cores()). If |
||||
discard_old_records is non-zero, then new records will displace older ones |
||||
when the log is full. This function must be called before any other |
||||
census_log functions. |
||||
*/ |
||||
void census_log_initialize(size_t size_in_mb, int discard_old_records); |
||||
|
||||
/* Shutdown the logging subsystem. Caller must ensure that:
|
||||
- no in progress or future call to any census_log functions |
||||
- no incomplete records |
||||
*/ |
||||
void census_log_shutdown(void); |
||||
|
||||
/* Allocates and returns a 'size' bytes record and marks it in use. A
|
||||
subsequent census_log_end_write() marks the record complete. The |
||||
'bytes_written' census_log_end_write() argument must be <= |
||||
'size'. Returns NULL if out-of-space AND: |
||||
- log is configured to keep old records OR |
||||
- all blocks are pinned by incomplete records. |
||||
*/ |
||||
void *census_log_start_write(size_t size); |
||||
|
||||
void census_log_end_write(void *record, size_t bytes_written); |
||||
|
||||
/* census_log_read_next() iterates over blocks with data and for each block
|
||||
returns a pointer to the first unread byte. The number of bytes that can be |
||||
read are returned in 'bytes_available'. Reader is expected to read all |
||||
available data. Reading the data consumes it i.e. it cannot be read again. |
||||
census_log_read_next() returns NULL if the end is reached i.e last block |
||||
is read. census_log_init_reader() starts the iteration or aborts the |
||||
current iteration. |
||||
*/ |
||||
void census_log_init_reader(void); |
||||
const void *census_log_read_next(size_t *bytes_available); |
||||
|
||||
/* Returns estimated remaining space across all blocks, in bytes. If log is
|
||||
configured to discard old records, returns total log space. Otherwise, |
||||
returns space available in empty blocks (partially filled blocks are |
||||
treated as full). |
||||
*/ |
||||
size_t census_log_remaining_space(void); |
||||
|
||||
/* Returns the number of times grpc_stats_log_start_write() failed due to
|
||||
out-of-space. */ |
||||
int census_log_out_of_space_count(void); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H */ |
@ -1,238 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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 <string.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/sync.h> |
||||
#include "src/core/ext/census/census_interface.h" |
||||
#include "src/core/ext/census/census_rpc_stats.h" |
||||
#include "src/core/ext/census/census_tracing.h" |
||||
#include "src/core/ext/census/hash_table.h" |
||||
#include "src/core/ext/census/window_stats.h" |
||||
#include "src/core/lib/support/murmur_hash.h" |
||||
#include "src/core/lib/support/string.h" |
||||
|
||||
#define NUM_INTERVALS 3 |
||||
#define MINUTE_INTERVAL 0 |
||||
#define HOUR_INTERVAL 1 |
||||
#define TOTAL_INTERVAL 2 |
||||
|
||||
/* for easier typing */ |
||||
typedef census_per_method_rpc_stats per_method_stats; |
||||
|
||||
/* Ensure mu is only initialized once. */ |
||||
static gpr_once g_stats_store_mu_init = GPR_ONCE_INIT; |
||||
/* Guards two stats stores. */ |
||||
static gpr_mu g_mu; |
||||
static census_ht *g_client_stats_store = NULL; |
||||
static census_ht *g_server_stats_store = NULL; |
||||
|
||||
static void init_mutex(void) { gpr_mu_init(&g_mu); } |
||||
|
||||
static void init_mutex_once(void) { |
||||
gpr_once_init(&g_stats_store_mu_init, init_mutex); |
||||
} |
||||
|
||||
static int cmp_str_keys(const void *k1, const void *k2) { |
||||
return strcmp((const char *)k1, (const char *)k2); |
||||
} |
||||
|
||||
/* TODO(hongyu): replace it with cityhash64 */ |
||||
static uint64_t simple_hash(const void *k) { |
||||
size_t len = strlen(k); |
||||
uint64_t higher = gpr_murmur_hash3((const char *)k, len / 2, 0); |
||||
return higher << 32 | |
||||
gpr_murmur_hash3((const char *)k + len / 2, len - len / 2, 0); |
||||
} |
||||
|
||||
static void delete_stats(void *stats) { |
||||
census_window_stats_destroy((struct census_window_stats *)stats); |
||||
} |
||||
|
||||
static void delete_key(void *key) { gpr_free(key); } |
||||
|
||||
static const census_ht_option ht_opt = { |
||||
CENSUS_HT_POINTER /* key type */, 1999 /* n_of_buckets */, |
||||
simple_hash /* hash function */, cmp_str_keys /* key comparator */, |
||||
delete_stats /* data deleter */, delete_key /* key deleter */ |
||||
}; |
||||
|
||||
static void init_rpc_stats(void *stats) { |
||||
memset(stats, 0, sizeof(census_rpc_stats)); |
||||
} |
||||
|
||||
static void stat_add_proportion(double p, void *base, const void *addme) { |
||||
census_rpc_stats *b = (census_rpc_stats *)base; |
||||
census_rpc_stats *a = (census_rpc_stats *)addme; |
||||
b->cnt += p * a->cnt; |
||||
b->rpc_error_cnt += p * a->rpc_error_cnt; |
||||
b->app_error_cnt += p * a->app_error_cnt; |
||||
b->elapsed_time_ms += p * a->elapsed_time_ms; |
||||
b->api_request_bytes += p * a->api_request_bytes; |
||||
b->wire_request_bytes += p * a->wire_request_bytes; |
||||
b->api_response_bytes += p * a->api_response_bytes; |
||||
b->wire_response_bytes += p * a->wire_response_bytes; |
||||
} |
||||
|
||||
static void stat_add(void *base, const void *addme) { |
||||
stat_add_proportion(1.0, base, addme); |
||||
} |
||||
|
||||
static gpr_timespec min_hour_total_intervals[3] = { |
||||
{60, 0}, {3600, 0}, {36000000, 0}}; |
||||
|
||||
static const census_window_stats_stat_info window_stats_settings = { |
||||
sizeof(census_rpc_stats), init_rpc_stats, stat_add, stat_add_proportion}; |
||||
|
||||
census_rpc_stats *census_rpc_stats_create_empty(void) { |
||||
census_rpc_stats *ret = |
||||
(census_rpc_stats *)gpr_malloc(sizeof(census_rpc_stats)); |
||||
memset(ret, 0, sizeof(census_rpc_stats)); |
||||
return ret; |
||||
} |
||||
|
||||
void census_aggregated_rpc_stats_set_empty(census_aggregated_rpc_stats *data) { |
||||
int i = 0; |
||||
for (i = 0; i < data->num_entries; i++) { |
||||
if (data->stats[i].method != NULL) { |
||||
gpr_free((void *)data->stats[i].method); |
||||
} |
||||
} |
||||
if (data->stats != NULL) { |
||||
gpr_free(data->stats); |
||||
} |
||||
data->num_entries = 0; |
||||
data->stats = NULL; |
||||
} |
||||
|
||||
static void record_stats(census_ht *store, census_op_id op_id, |
||||
const census_rpc_stats *stats) { |
||||
gpr_mu_lock(&g_mu); |
||||
if (store != NULL) { |
||||
census_trace_obj *trace = NULL; |
||||
census_internal_lock_trace_store(); |
||||
trace = census_get_trace_obj_locked(op_id); |
||||
if (trace != NULL) { |
||||
const char *method_name = census_get_trace_method_name(trace); |
||||
struct census_window_stats *window_stats = NULL; |
||||
census_ht_key key; |
||||
key.ptr = (void *)method_name; |
||||
window_stats = census_ht_find(store, key); |
||||
census_internal_unlock_trace_store(); |
||||
if (window_stats == NULL) { |
||||
window_stats = census_window_stats_create(3, min_hour_total_intervals, |
||||
30, &window_stats_settings); |
||||
key.ptr = gpr_strdup(key.ptr); |
||||
census_ht_insert(store, key, (void *)window_stats); |
||||
} |
||||
census_window_stats_add(window_stats, gpr_now(GPR_CLOCK_REALTIME), stats); |
||||
} else { |
||||
census_internal_unlock_trace_store(); |
||||
} |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
void census_record_rpc_client_stats(census_op_id op_id, |
||||
const census_rpc_stats *stats) { |
||||
record_stats(g_client_stats_store, op_id, stats); |
||||
} |
||||
|
||||
void census_record_rpc_server_stats(census_op_id op_id, |
||||
const census_rpc_stats *stats) { |
||||
record_stats(g_server_stats_store, op_id, stats); |
||||
} |
||||
|
||||
/* Get stats from input stats store */ |
||||
static void get_stats(census_ht *store, census_aggregated_rpc_stats *data) { |
||||
GPR_ASSERT(data != NULL); |
||||
if (data->num_entries != 0) { |
||||
census_aggregated_rpc_stats_set_empty(data); |
||||
} |
||||
gpr_mu_lock(&g_mu); |
||||
if (store != NULL) { |
||||
size_t n; |
||||
unsigned i, j; |
||||
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); |
||||
census_ht_kv *kv = census_ht_get_all_elements(store, &n); |
||||
if (kv != NULL) { |
||||
data->num_entries = n; |
||||
data->stats = |
||||
(per_method_stats *)gpr_malloc(sizeof(per_method_stats) * n); |
||||
for (i = 0; i < n; i++) { |
||||
census_window_stats_sums sums[NUM_INTERVALS]; |
||||
for (j = 0; j < NUM_INTERVALS; j++) { |
||||
sums[j].statistic = (void *)census_rpc_stats_create_empty(); |
||||
} |
||||
data->stats[i].method = gpr_strdup(kv[i].k.ptr); |
||||
census_window_stats_get_sums(kv[i].v, now, sums); |
||||
data->stats[i].minute_stats = |
||||
*(census_rpc_stats *)sums[MINUTE_INTERVAL].statistic; |
||||
data->stats[i].hour_stats = |
||||
*(census_rpc_stats *)sums[HOUR_INTERVAL].statistic; |
||||
data->stats[i].total_stats = |
||||
*(census_rpc_stats *)sums[TOTAL_INTERVAL].statistic; |
||||
for (j = 0; j < NUM_INTERVALS; j++) { |
||||
gpr_free(sums[j].statistic); |
||||
} |
||||
} |
||||
gpr_free(kv); |
||||
} |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
void census_get_client_stats(census_aggregated_rpc_stats *data) { |
||||
get_stats(g_client_stats_store, data); |
||||
} |
||||
|
||||
void census_get_server_stats(census_aggregated_rpc_stats *data) { |
||||
get_stats(g_server_stats_store, data); |
||||
} |
||||
|
||||
void census_stats_store_init(void) { |
||||
init_mutex_once(); |
||||
gpr_mu_lock(&g_mu); |
||||
if (g_client_stats_store == NULL && g_server_stats_store == NULL) { |
||||
g_client_stats_store = census_ht_create(&ht_opt); |
||||
g_server_stats_store = census_ht_create(&ht_opt); |
||||
} else { |
||||
gpr_log(GPR_ERROR, "Census stats store already initialized."); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
void census_stats_store_shutdown(void) { |
||||
init_mutex_once(); |
||||
gpr_mu_lock(&g_mu); |
||||
if (g_client_stats_store != NULL) { |
||||
census_ht_destroy(g_client_stats_store); |
||||
g_client_stats_store = NULL; |
||||
} else { |
||||
gpr_log(GPR_ERROR, "Census server stats store not initialized."); |
||||
} |
||||
if (g_server_stats_store != NULL) { |
||||
census_ht_destroy(g_server_stats_store); |
||||
g_server_stats_store = NULL; |
||||
} else { |
||||
gpr_log(GPR_ERROR, "Census client stats store not initialized."); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
@ -1,86 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_CENSUS_RPC_STATS_H |
||||
#define GRPC_CORE_EXT_CENSUS_CENSUS_RPC_STATS_H |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
#include "src/core/ext/census/census_interface.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
struct census_rpc_stats { |
||||
uint64_t cnt; |
||||
uint64_t rpc_error_cnt; |
||||
uint64_t app_error_cnt; |
||||
double elapsed_time_ms; |
||||
double api_request_bytes; |
||||
double wire_request_bytes; |
||||
double api_response_bytes; |
||||
double wire_response_bytes; |
||||
}; |
||||
|
||||
/* Creates an empty rpc stats object on heap. */ |
||||
census_rpc_stats *census_rpc_stats_create_empty(void); |
||||
|
||||
typedef struct census_per_method_rpc_stats { |
||||
const char *method; |
||||
census_rpc_stats minute_stats; /* cumulative stats in the past minute */ |
||||
census_rpc_stats hour_stats; /* cumulative stats in the past hour */ |
||||
census_rpc_stats total_stats; /* cumulative stats from last gc */ |
||||
} census_per_method_rpc_stats; |
||||
|
||||
typedef struct census_aggregated_rpc_stats { |
||||
int num_entries; |
||||
census_per_method_rpc_stats *stats; |
||||
} census_aggregated_rpc_stats; |
||||
|
||||
/* Initializes an aggregated rpc stats object to an empty state. */ |
||||
void census_aggregated_rpc_stats_set_empty(census_aggregated_rpc_stats *data); |
||||
|
||||
/* Records client side stats of a rpc. */ |
||||
void census_record_rpc_client_stats(census_op_id op_id, |
||||
const census_rpc_stats *stats); |
||||
|
||||
/* Records server side stats of a rpc. */ |
||||
void census_record_rpc_server_stats(census_op_id op_id, |
||||
const census_rpc_stats *stats); |
||||
|
||||
/* The following two functions are intended for inprocess query of
|
||||
per-service per-method stats from grpc implementations. */ |
||||
|
||||
/* Populates *data_map with server side aggregated per-service per-method
|
||||
stats. |
||||
DO NOT CALL from outside of grpc code. */ |
||||
void census_get_server_stats(census_aggregated_rpc_stats *data_map); |
||||
|
||||
/* Populates *data_map with client side aggregated per-service per-method
|
||||
stats. |
||||
DO NOT CALL from outside of grpc code. */ |
||||
void census_get_client_stats(census_aggregated_rpc_stats *data_map); |
||||
|
||||
void census_stats_store_init(void); |
||||
void census_stats_store_shutdown(void); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_RPC_STATS_H */ |
@ -1,226 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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 "src/core/ext/census/census_tracing.h" |
||||
#include "src/core/ext/census/census_interface.h" |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/port_platform.h> |
||||
#include <grpc/support/sync.h> |
||||
#include "src/core/ext/census/hash_table.h" |
||||
#include "src/core/lib/support/string.h" |
||||
|
||||
void census_trace_obj_destroy(census_trace_obj *obj) { |
||||
census_trace_annotation *p = obj->annotations; |
||||
while (p != NULL) { |
||||
census_trace_annotation *next = p->next; |
||||
gpr_free(p); |
||||
p = next; |
||||
} |
||||
gpr_free(obj->method); |
||||
gpr_free(obj); |
||||
} |
||||
|
||||
static void delete_trace_obj(void *obj) { |
||||
census_trace_obj_destroy((census_trace_obj *)obj); |
||||
} |
||||
|
||||
static const census_ht_option ht_opt = { |
||||
CENSUS_HT_UINT64 /* key type */, |
||||
571 /* n_of_buckets */, |
||||
NULL /* hash */, |
||||
NULL /* compare_keys */, |
||||
delete_trace_obj /* delete data */, |
||||
NULL /* delete key */ |
||||
}; |
||||
|
||||
static gpr_once g_init_mutex_once = GPR_ONCE_INIT; |
||||
static gpr_mu g_mu; /* Guards following two static variables. */ |
||||
static census_ht *g_trace_store = NULL; |
||||
static uint64_t g_id = 0; |
||||
|
||||
static census_ht_key op_id_as_key(census_op_id *id) { |
||||
return *(census_ht_key *)id; |
||||
} |
||||
|
||||
static uint64_t op_id_2_uint64(census_op_id *id) { |
||||
uint64_t ret; |
||||
memcpy(&ret, id, sizeof(census_op_id)); |
||||
return ret; |
||||
} |
||||
|
||||
static void init_mutex(void) { gpr_mu_init(&g_mu); } |
||||
|
||||
static void init_mutex_once(void) { |
||||
gpr_once_init(&g_init_mutex_once, init_mutex); |
||||
} |
||||
|
||||
census_op_id census_tracing_start_op(void) { |
||||
gpr_mu_lock(&g_mu); |
||||
{ |
||||
census_trace_obj *ret = gpr_malloc(sizeof(census_trace_obj)); |
||||
memset(ret, 0, sizeof(census_trace_obj)); |
||||
g_id++; |
||||
memcpy(&ret->id, &g_id, sizeof(census_op_id)); |
||||
ret->rpc_stats.cnt = 1; |
||||
ret->ts = gpr_now(GPR_CLOCK_REALTIME); |
||||
census_ht_insert(g_trace_store, op_id_as_key(&ret->id), (void *)ret); |
||||
gpr_log(GPR_DEBUG, "Start tracing for id %lu", g_id); |
||||
gpr_mu_unlock(&g_mu); |
||||
return ret->id; |
||||
} |
||||
} |
||||
|
||||
int census_add_method_tag(census_op_id op_id, const char *method) { |
||||
int ret = 0; |
||||
census_trace_obj *trace = NULL; |
||||
gpr_mu_lock(&g_mu); |
||||
trace = census_ht_find(g_trace_store, op_id_as_key(&op_id)); |
||||
if (trace == NULL) { |
||||
ret = 1; |
||||
} else { |
||||
trace->method = gpr_strdup(method); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
return ret; |
||||
} |
||||
|
||||
void census_tracing_print(census_op_id op_id, const char *anno_txt) { |
||||
census_trace_obj *trace = NULL; |
||||
gpr_mu_lock(&g_mu); |
||||
trace = census_ht_find(g_trace_store, op_id_as_key(&op_id)); |
||||
if (trace != NULL) { |
||||
census_trace_annotation *anno = gpr_malloc(sizeof(census_trace_annotation)); |
||||
anno->ts = gpr_now(GPR_CLOCK_REALTIME); |
||||
{ |
||||
char *d = anno->txt; |
||||
const char *s = anno_txt; |
||||
int n = 0; |
||||
for (; n < CENSUS_MAX_ANNOTATION_LENGTH && *s != '\0'; ++n) { |
||||
*d++ = *s++; |
||||
} |
||||
*d = '\0'; |
||||
} |
||||
anno->next = trace->annotations; |
||||
trace->annotations = anno; |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
void census_tracing_end_op(census_op_id op_id) { |
||||
census_trace_obj *trace = NULL; |
||||
gpr_mu_lock(&g_mu); |
||||
trace = census_ht_find(g_trace_store, op_id_as_key(&op_id)); |
||||
if (trace != NULL) { |
||||
trace->rpc_stats.elapsed_time_ms = gpr_timespec_to_micros( |
||||
gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), trace->ts)); |
||||
gpr_log(GPR_DEBUG, "End tracing for id %lu, method %s, latency %f us", |
||||
op_id_2_uint64(&op_id), trace->method, |
||||
trace->rpc_stats.elapsed_time_ms); |
||||
census_ht_erase(g_trace_store, op_id_as_key(&op_id)); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
void census_tracing_init(void) { |
||||
init_mutex_once(); |
||||
gpr_mu_lock(&g_mu); |
||||
if (g_trace_store == NULL) { |
||||
g_id = 1; |
||||
g_trace_store = census_ht_create(&ht_opt); |
||||
} else { |
||||
gpr_log(GPR_ERROR, "Census trace store already initialized."); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
void census_tracing_shutdown(void) { |
||||
gpr_mu_lock(&g_mu); |
||||
if (g_trace_store != NULL) { |
||||
census_ht_destroy(g_trace_store); |
||||
g_trace_store = NULL; |
||||
} else { |
||||
gpr_log(GPR_ERROR, "Census trace store is not initialized."); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
void census_internal_lock_trace_store(void) { gpr_mu_lock(&g_mu); } |
||||
|
||||
void census_internal_unlock_trace_store(void) { gpr_mu_unlock(&g_mu); } |
||||
|
||||
census_trace_obj *census_get_trace_obj_locked(census_op_id op_id) { |
||||
if (g_trace_store == NULL) { |
||||
gpr_log(GPR_ERROR, "Census trace store is not initialized."); |
||||
return NULL; |
||||
} |
||||
return (census_trace_obj *)census_ht_find(g_trace_store, |
||||
op_id_as_key(&op_id)); |
||||
} |
||||
|
||||
const char *census_get_trace_method_name(const census_trace_obj *trace) { |
||||
return trace->method; |
||||
} |
||||
|
||||
static census_trace_annotation *dup_annotation_chain( |
||||
census_trace_annotation *from) { |
||||
census_trace_annotation *ret = NULL; |
||||
census_trace_annotation **to = &ret; |
||||
for (; from != NULL; from = from->next) { |
||||
*to = gpr_malloc(sizeof(census_trace_annotation)); |
||||
memcpy(*to, from, sizeof(census_trace_annotation)); |
||||
to = &(*to)->next; |
||||
} |
||||
return ret; |
||||
} |
||||
|
||||
static census_trace_obj *trace_obj_dup(census_trace_obj *from) { |
||||
census_trace_obj *to = NULL; |
||||
GPR_ASSERT(from != NULL); |
||||
to = gpr_malloc(sizeof(census_trace_obj)); |
||||
to->id = from->id; |
||||
to->ts = from->ts; |
||||
to->rpc_stats = from->rpc_stats; |
||||
to->method = gpr_strdup(from->method); |
||||
to->annotations = dup_annotation_chain(from->annotations); |
||||
return to; |
||||
} |
||||
|
||||
census_trace_obj **census_get_active_ops(int *num_active_ops) { |
||||
census_trace_obj **ret = NULL; |
||||
gpr_mu_lock(&g_mu); |
||||
if (g_trace_store != NULL) { |
||||
size_t n = 0; |
||||
census_ht_kv *all_kvs = census_ht_get_all_elements(g_trace_store, &n); |
||||
*num_active_ops = (int)n; |
||||
if (n != 0) { |
||||
size_t i = 0; |
||||
ret = gpr_malloc(sizeof(census_trace_obj *) * n); |
||||
for (i = 0; i < n; i++) { |
||||
ret[i] = trace_obj_dup((census_trace_obj *)all_kvs[i].v); |
||||
} |
||||
} |
||||
gpr_free(all_kvs); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
return ret; |
||||
} |
@ -1,81 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_CENSUS_TRACING_H |
||||
#define GRPC_CORE_EXT_CENSUS_CENSUS_TRACING_H |
||||
|
||||
#include <grpc/support/time.h> |
||||
#include "src/core/ext/census/census_rpc_stats.h" |
||||
|
||||
/* WARNING: The data structures and APIs provided by this file are for GRPC
|
||||
library's internal use ONLY. They might be changed in backward-incompatible |
||||
ways and are not subject to any deprecation policy. |
||||
They are not recommended for external use. |
||||
*/ |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Struct for a trace annotation. */ |
||||
typedef struct census_trace_annotation { |
||||
gpr_timespec ts; /* timestamp of the annotation */ |
||||
char txt[CENSUS_MAX_ANNOTATION_LENGTH + 1]; /* actual txt annotation */ |
||||
struct census_trace_annotation *next; |
||||
} census_trace_annotation; |
||||
|
||||
typedef struct census_trace_obj { |
||||
census_op_id id; |
||||
gpr_timespec ts; |
||||
census_rpc_stats rpc_stats; |
||||
char *method; |
||||
census_trace_annotation *annotations; |
||||
} census_trace_obj; |
||||
|
||||
/* Deletes trace object. */ |
||||
void census_trace_obj_destroy(census_trace_obj *obj); |
||||
|
||||
/* Initializes trace store. This function is thread safe. */ |
||||
void census_tracing_init(void); |
||||
|
||||
/* Shutsdown trace store. This function is thread safe. */ |
||||
void census_tracing_shutdown(void); |
||||
|
||||
/* Gets trace obj corresponding to the input op_id. Returns NULL if trace store
|
||||
is not initialized or trace obj is not found. Requires trace store being |
||||
locked before calling this function. */ |
||||
census_trace_obj *census_get_trace_obj_locked(census_op_id op_id); |
||||
|
||||
/* The following two functions acquire and release the trace store global lock.
|
||||
They are for census internal use only. */ |
||||
void census_internal_lock_trace_store(void); |
||||
void census_internal_unlock_trace_store(void); |
||||
|
||||
/* Gets method name associated with the input trace object. */ |
||||
const char *census_get_trace_method_name(const census_trace_obj *trace); |
||||
|
||||
/* Returns an array of pointers to trace objects of currently active operations
|
||||
and fills in number of active operations. Returns NULL if there are no active |
||||
operations. |
||||
Caller owns the returned objects. */ |
||||
census_trace_obj **census_get_active_ops(int *num_active_ops); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_TRACING_H */ |
@ -1,496 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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 <grpc/census.h> |
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/port_platform.h> |
||||
#include <grpc/support/useful.h> |
||||
#include <stdbool.h> |
||||
#include <string.h> |
||||
#include "src/core/lib/support/string.h" |
||||
|
||||
// Functions in this file support the public context API, including
|
||||
// encoding/decoding as part of context propagation across RPC's. The overall
|
||||
// requirements (in approximate priority order) for the
|
||||
// context representation:
|
||||
// 1. Efficient conversion to/from wire format
|
||||
// 2. Minimal bytes used on-wire
|
||||
// 3. Efficient context creation
|
||||
// 4. Efficient lookup of tag value for a key
|
||||
// 5. Efficient iteration over tags
|
||||
// 6. Minimal memory footprint
|
||||
//
|
||||
// Notes on tradeoffs/decisions:
|
||||
// * tag includes 1 byte length of key, as well as nil-terminating byte. These
|
||||
// are to aid in efficient parsing and the ability to directly return key
|
||||
// strings. This is more important than saving a single byte/tag on the wire.
|
||||
// * The wire encoding uses only single byte values. This eliminates the need
|
||||
// to handle endian-ness conversions. It also means there is a hard upper
|
||||
// limit of 255 for both CENSUS_MAX_TAG_KV_LEN and CENSUS_MAX_PROPAGATED_TAGS.
|
||||
// * Keep all tag information (keys/values/flags) in a single memory buffer,
|
||||
// that can be directly copied to the wire.
|
||||
|
||||
// min and max valid chars in tag keys and values. All printable ASCII is OK.
|
||||
#define MIN_VALID_TAG_CHAR 32 // ' '
|
||||
#define MAX_VALID_TAG_CHAR 126 // '~'
|
||||
|
||||
// Structure representing a set of tags. Essentially a count of number of tags
|
||||
// present, and pointer to a chunk of memory that contains the per-tag details.
|
||||
struct tag_set { |
||||
int ntags; // number of tags.
|
||||
int ntags_alloc; // ntags + number of deleted tags (total number of tags
|
||||
// in all of kvm). This will always be == ntags, except during the process
|
||||
// of building a new tag set.
|
||||
size_t kvm_size; // number of bytes allocated for key/value storage.
|
||||
size_t kvm_used; // number of bytes of used key/value memory
|
||||
char *kvm; // key/value memory. Consists of repeated entries of:
|
||||
// Offset Size Description
|
||||
// 0 1 Key length, including trailing 0. (K)
|
||||
// 1 1 Value length, including trailing 0 (V)
|
||||
// 2 1 Flags
|
||||
// 3 K Key bytes
|
||||
// 3 + K V Value bytes
|
||||
//
|
||||
// We refer to the first 3 entries as the 'tag header'. If extra values are
|
||||
// introduced in the header, you will need to modify the TAG_HEADER_SIZE
|
||||
// constant, the raw_tag structure (and everything that uses it) and the
|
||||
// encode/decode functions appropriately.
|
||||
}; |
||||
|
||||
// Number of bytes in tag header.
|
||||
#define TAG_HEADER_SIZE 3 // key length (1) + value length (1) + flags (1)
|
||||
// Offsets to tag header entries.
|
||||
#define KEY_LEN_OFFSET 0 |
||||
#define VALUE_LEN_OFFSET 1 |
||||
#define FLAG_OFFSET 2 |
||||
|
||||
// raw_tag represents the raw-storage form of a tag in the kvm of a tag_set.
|
||||
struct raw_tag { |
||||
uint8_t key_len; |
||||
uint8_t value_len; |
||||
uint8_t flags; |
||||
char *key; |
||||
char *value; |
||||
}; |
||||
|
||||
// Use a reserved flag bit for indication of deleted tag.
|
||||
#define CENSUS_TAG_DELETED CENSUS_TAG_RESERVED |
||||
#define CENSUS_TAG_IS_DELETED(flags) (flags & CENSUS_TAG_DELETED) |
||||
|
||||
// Primary representation of a context. Composed of 2 underlying tag_set
|
||||
// structs, one each for propagated and local (non-propagated) tags. This is
|
||||
// to efficiently support tag encoding/decoding.
|
||||
// TODO(aveitch): need to add tracing id's/structure.
|
||||
struct census_context { |
||||
struct tag_set tags[2]; |
||||
census_context_status status; |
||||
}; |
||||
|
||||
// Indices into the tags member of census_context
|
||||
#define PROPAGATED_TAGS 0 |
||||
#define LOCAL_TAGS 1 |
||||
|
||||
// Validate (check all characters are in range and size is less than limit) a
|
||||
// key or value string. Returns 0 if the string is invalid, or the length
|
||||
// (including terminator) if valid.
|
||||
static size_t validate_tag(const char *kv) { |
||||
size_t len = 1; |
||||
char ch; |
||||
while ((ch = *kv++) != 0) { |
||||
if (ch < MIN_VALID_TAG_CHAR || ch > MAX_VALID_TAG_CHAR) { |
||||
return 0; |
||||
} |
||||
len++; |
||||
} |
||||
if (len > CENSUS_MAX_TAG_KV_LEN) { |
||||
return 0; |
||||
} |
||||
return len; |
||||
} |
||||
|
||||
// Extract a raw tag given a pointer (raw) to the tag header. Allow for some
|
||||
// extra bytes in the tag header (see encode/decode functions for usage: this
|
||||
// allows for future expansion of the tag header).
|
||||
static char *decode_tag(struct raw_tag *tag, char *header, int offset) { |
||||
tag->key_len = (uint8_t)(*header++); |
||||
tag->value_len = (uint8_t)(*header++); |
||||
tag->flags = (uint8_t)(*header++); |
||||
header += offset; |
||||
tag->key = header; |
||||
header += tag->key_len; |
||||
tag->value = header; |
||||
return header + tag->value_len; |
||||
} |
||||
|
||||
// Make a copy (in 'to') of an existing tag_set.
|
||||
static void tag_set_copy(struct tag_set *to, const struct tag_set *from) { |
||||
memcpy(to, from, sizeof(struct tag_set)); |
||||
to->kvm = (char *)gpr_malloc(to->kvm_size); |
||||
memcpy(to->kvm, from->kvm, from->kvm_used); |
||||
} |
||||
|
||||
// Delete a tag from a tag_set, if it exists (returns true if it did).
|
||||
static bool tag_set_delete_tag(struct tag_set *tags, const char *key, |
||||
size_t key_len) { |
||||
char *kvp = tags->kvm; |
||||
for (int i = 0; i < tags->ntags_alloc; i++) { |
||||
uint8_t *flags = (uint8_t *)(kvp + FLAG_OFFSET); |
||||
struct raw_tag tag; |
||||
kvp = decode_tag(&tag, kvp, 0); |
||||
if (CENSUS_TAG_IS_DELETED(tag.flags)) continue; |
||||
if ((key_len == tag.key_len) && (memcmp(key, tag.key, key_len) == 0)) { |
||||
*flags |= CENSUS_TAG_DELETED; |
||||
tags->ntags--; |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
// Delete a tag from a context, return true if it existed.
|
||||
static bool context_delete_tag(census_context *context, const census_tag *tag, |
||||
size_t key_len) { |
||||
return ( |
||||
tag_set_delete_tag(&context->tags[LOCAL_TAGS], tag->key, key_len) || |
||||
tag_set_delete_tag(&context->tags[PROPAGATED_TAGS], tag->key, key_len)); |
||||
} |
||||
|
||||
// Add a tag to a tag_set. Return true on success, false if the tag could
|
||||
// not be added because of constraints on tag set size. This function should
|
||||
// not be called if the tag may already exist (in a non-deleted state) in
|
||||
// the tag_set, as that would result in two tags with the same key.
|
||||
static bool tag_set_add_tag(struct tag_set *tags, const census_tag *tag, |
||||
size_t key_len, size_t value_len) { |
||||
if (tags->ntags == CENSUS_MAX_PROPAGATED_TAGS) { |
||||
return false; |
||||
} |
||||
const size_t tag_size = key_len + value_len + TAG_HEADER_SIZE; |
||||
if (tags->kvm_used + tag_size > tags->kvm_size) { |
||||
// allocate new memory if needed
|
||||
tags->kvm_size += 2 * CENSUS_MAX_TAG_KV_LEN + TAG_HEADER_SIZE; |
||||
char *new_kvm = (char *)gpr_malloc(tags->kvm_size); |
||||
if (tags->kvm_used > 0) memcpy(new_kvm, tags->kvm, tags->kvm_used); |
||||
gpr_free(tags->kvm); |
||||
tags->kvm = new_kvm; |
||||
} |
||||
char *kvp = tags->kvm + tags->kvm_used; |
||||
*kvp++ = (char)key_len; |
||||
*kvp++ = (char)value_len; |
||||
// ensure reserved flags are not used.
|
||||
*kvp++ = (char)(tag->flags & (CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS)); |
||||
memcpy(kvp, tag->key, key_len); |
||||
kvp += key_len; |
||||
memcpy(kvp, tag->value, value_len); |
||||
tags->kvm_used += tag_size; |
||||
tags->ntags++; |
||||
tags->ntags_alloc++; |
||||
return true; |
||||
} |
||||
|
||||
// Add/modify/delete a tag to/in a context. Caller must validate that tag key
|
||||
// etc. are valid.
|
||||
static void context_modify_tag(census_context *context, const census_tag *tag, |
||||
size_t key_len, size_t value_len) { |
||||
// First delete the tag if it is already present.
|
||||
bool deleted = context_delete_tag(context, tag, key_len); |
||||
bool added = false; |
||||
if (CENSUS_TAG_IS_PROPAGATED(tag->flags)) { |
||||
added = tag_set_add_tag(&context->tags[PROPAGATED_TAGS], tag, key_len, |
||||
value_len); |
||||
} else { |
||||
added = |
||||
tag_set_add_tag(&context->tags[LOCAL_TAGS], tag, key_len, value_len); |
||||
} |
||||
|
||||
if (deleted) { |
||||
context->status.n_modified_tags++; |
||||
} else { |
||||
if (added) { |
||||
context->status.n_added_tags++; |
||||
} else { |
||||
context->status.n_ignored_tags++; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Remove memory used for deleted tags from a tag set. Basic algorithm:
|
||||
// 1) Walk through tag set to find first deleted tag. Record where it is.
|
||||
// 2) Find the next not-deleted tag. Copy all of kvm from there to the end
|
||||
// "over" the deleted tags
|
||||
// 3) repeat #1 and #2 until we have seen all tags
|
||||
// 4) if we are still looking for a not-deleted tag, then all the end portion
|
||||
// of the kvm is deleted. Just reduce the used amount of memory by the
|
||||
// appropriate amount.
|
||||
static void tag_set_flatten(struct tag_set *tags) { |
||||
if (tags->ntags == tags->ntags_alloc) return; |
||||
bool found_deleted = false; // found a deleted tag.
|
||||
char *kvp = tags->kvm; |
||||
char *dbase = NULL; // record location of deleted tag
|
||||
for (int i = 0; i < tags->ntags_alloc; i++) { |
||||
struct raw_tag tag; |
||||
char *next_kvp = decode_tag(&tag, kvp, 0); |
||||
if (found_deleted) { |
||||
if (!CENSUS_TAG_IS_DELETED(tag.flags)) { |
||||
ptrdiff_t reduce = kvp - dbase; // #bytes in deleted tags
|
||||
GPR_ASSERT(reduce > 0); |
||||
ptrdiff_t copy_size = tags->kvm + tags->kvm_used - kvp; |
||||
GPR_ASSERT(copy_size > 0); |
||||
memmove(dbase, kvp, (size_t)copy_size); |
||||
tags->kvm_used -= (size_t)reduce; |
||||
next_kvp -= reduce; |
||||
found_deleted = false; |
||||
} |
||||
} else { |
||||
if (CENSUS_TAG_IS_DELETED(tag.flags)) { |
||||
dbase = kvp; |
||||
found_deleted = true; |
||||
} |
||||
} |
||||
kvp = next_kvp; |
||||
} |
||||
if (found_deleted) { |
||||
GPR_ASSERT(dbase > tags->kvm); |
||||
tags->kvm_used = (size_t)(dbase - tags->kvm); |
||||
} |
||||
tags->ntags_alloc = tags->ntags; |
||||
} |
||||
|
||||
census_context *census_context_create(const census_context *base, |
||||
const census_tag *tags, int ntags, |
||||
census_context_status const **status) { |
||||
census_context *context = |
||||
(census_context *)gpr_malloc(sizeof(census_context)); |
||||
// If we are given a base, copy it into our new tag set. Otherwise set it
|
||||
// to zero/NULL everything.
|
||||
if (base == NULL) { |
||||
memset(context, 0, sizeof(census_context)); |
||||
} else { |
||||
tag_set_copy(&context->tags[PROPAGATED_TAGS], &base->tags[PROPAGATED_TAGS]); |
||||
tag_set_copy(&context->tags[LOCAL_TAGS], &base->tags[LOCAL_TAGS]); |
||||
memset(&context->status, 0, sizeof(context->status)); |
||||
} |
||||
// Walk over the additional tags and, for those that aren't invalid, modify
|
||||
// the context to add/replace/delete as required.
|
||||
for (int i = 0; i < ntags; i++) { |
||||
const census_tag *tag = &tags[i]; |
||||
size_t key_len = validate_tag(tag->key); |
||||
// ignore the tag if it is invalid or too short.
|
||||
if (key_len <= 1) { |
||||
context->status.n_invalid_tags++; |
||||
} else { |
||||
if (tag->value != NULL) { |
||||
size_t value_len = validate_tag(tag->value); |
||||
if (value_len != 0) { |
||||
context_modify_tag(context, tag, key_len, value_len); |
||||
} else { |
||||
context->status.n_invalid_tags++; |
||||
} |
||||
} else { |
||||
if (context_delete_tag(context, tag, key_len)) { |
||||
context->status.n_deleted_tags++; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
// Remove any deleted tags, update status if needed, and return.
|
||||
tag_set_flatten(&context->tags[PROPAGATED_TAGS]); |
||||
tag_set_flatten(&context->tags[LOCAL_TAGS]); |
||||
context->status.n_propagated_tags = context->tags[PROPAGATED_TAGS].ntags; |
||||
context->status.n_local_tags = context->tags[LOCAL_TAGS].ntags; |
||||
if (status) { |
||||
*status = &context->status; |
||||
} |
||||
return context; |
||||
} |
||||
|
||||
const census_context_status *census_context_get_status( |
||||
const census_context *context) { |
||||
return &context->status; |
||||
} |
||||
|
||||
void census_context_destroy(census_context *context) { |
||||
gpr_free(context->tags[PROPAGATED_TAGS].kvm); |
||||
gpr_free(context->tags[LOCAL_TAGS].kvm); |
||||
gpr_free(context); |
||||
} |
||||
|
||||
void census_context_initialize_iterator(const census_context *context, |
||||
census_context_iterator *iterator) { |
||||
iterator->context = context; |
||||
iterator->index = 0; |
||||
if (context->tags[PROPAGATED_TAGS].ntags != 0) { |
||||
iterator->base = PROPAGATED_TAGS; |
||||
iterator->kvm = context->tags[PROPAGATED_TAGS].kvm; |
||||
} else if (context->tags[LOCAL_TAGS].ntags != 0) { |
||||
iterator->base = LOCAL_TAGS; |
||||
iterator->kvm = context->tags[LOCAL_TAGS].kvm; |
||||
} else { |
||||
iterator->base = -1; |
||||
} |
||||
} |
||||
|
||||
int census_context_next_tag(census_context_iterator *iterator, |
||||
census_tag *tag) { |
||||
if (iterator->base < 0) { |
||||
return 0; |
||||
} |
||||
struct raw_tag raw; |
||||
iterator->kvm = decode_tag(&raw, iterator->kvm, 0); |
||||
tag->key = raw.key; |
||||
tag->value = raw.value; |
||||
tag->flags = raw.flags; |
||||
if (++iterator->index == iterator->context->tags[iterator->base].ntags) { |
||||
do { |
||||
if (iterator->base == LOCAL_TAGS) { |
||||
iterator->base = -1; |
||||
return 1; |
||||
} |
||||
} while (iterator->context->tags[++iterator->base].ntags == 0); |
||||
iterator->index = 0; |
||||
iterator->kvm = iterator->context->tags[iterator->base].kvm; |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
// Find a tag in a tag_set by key. Return true if found, false otherwise.
|
||||
static bool tag_set_get_tag(const struct tag_set *tags, const char *key, |
||||
size_t key_len, census_tag *tag) { |
||||
char *kvp = tags->kvm; |
||||
for (int i = 0; i < tags->ntags; i++) { |
||||
struct raw_tag raw; |
||||
kvp = decode_tag(&raw, kvp, 0); |
||||
if (key_len == raw.key_len && memcmp(raw.key, key, key_len) == 0) { |
||||
tag->key = raw.key; |
||||
tag->value = raw.value; |
||||
tag->flags = raw.flags; |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
int census_context_get_tag(const census_context *context, const char *key, |
||||
census_tag *tag) { |
||||
size_t key_len = strlen(key) + 1; |
||||
if (key_len == 1) { |
||||
return 0; |
||||
} |
||||
if (tag_set_get_tag(&context->tags[PROPAGATED_TAGS], key, key_len, tag) || |
||||
tag_set_get_tag(&context->tags[LOCAL_TAGS], key, key_len, tag)) { |
||||
return 1; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
// Context encoding and decoding functions.
|
||||
//
|
||||
// Wire format for tag_set's on the wire:
|
||||
//
|
||||
// First, a tag set header:
|
||||
//
|
||||
// offset bytes description
|
||||
// 0 1 version number
|
||||
// 1 1 number of bytes in this header. This allows for future
|
||||
// expansion.
|
||||
// 2 1 number of bytes in each tag header.
|
||||
// 3 1 ntags value from tag set.
|
||||
//
|
||||
// This is followed by the key/value memory from struct tag_set.
|
||||
|
||||
#define ENCODED_VERSION 0 // Version number
|
||||
#define ENCODED_HEADER_SIZE 4 // size of tag set header
|
||||
|
||||
// Encode a tag set. Returns 0 if buffer is too small.
|
||||
static size_t tag_set_encode(const struct tag_set *tags, char *buffer, |
||||
size_t buf_size) { |
||||
if (buf_size < ENCODED_HEADER_SIZE + tags->kvm_used) { |
||||
return 0; |
||||
} |
||||
buf_size -= ENCODED_HEADER_SIZE; |
||||
*buffer++ = (char)ENCODED_VERSION; |
||||
*buffer++ = (char)ENCODED_HEADER_SIZE; |
||||
*buffer++ = (char)TAG_HEADER_SIZE; |
||||
*buffer++ = (char)tags->ntags; |
||||
if (tags->ntags == 0) { |
||||
return ENCODED_HEADER_SIZE; |
||||
} |
||||
memcpy(buffer, tags->kvm, tags->kvm_used); |
||||
return ENCODED_HEADER_SIZE + tags->kvm_used; |
||||
} |
||||
|
||||
size_t census_context_encode(const census_context *context, char *buffer, |
||||
size_t buf_size) { |
||||
return tag_set_encode(&context->tags[PROPAGATED_TAGS], buffer, buf_size); |
||||
} |
||||
|
||||
// Decode a tag set.
|
||||
static void tag_set_decode(struct tag_set *tags, const char *buffer, |
||||
size_t size) { |
||||
uint8_t version = (uint8_t)(*buffer++); |
||||
uint8_t header_size = (uint8_t)(*buffer++); |
||||
uint8_t tag_header_size = (uint8_t)(*buffer++); |
||||
tags->ntags = tags->ntags_alloc = (int)(*buffer++); |
||||
if (tags->ntags == 0) { |
||||
tags->ntags_alloc = 0; |
||||
tags->kvm_size = 0; |
||||
tags->kvm_used = 0; |
||||
tags->kvm = NULL; |
||||
return; |
||||
} |
||||
if (header_size != ENCODED_HEADER_SIZE) { |
||||
GPR_ASSERT(version != ENCODED_VERSION); |
||||
GPR_ASSERT(ENCODED_HEADER_SIZE < header_size); |
||||
buffer += (header_size - ENCODED_HEADER_SIZE); |
||||
} |
||||
tags->kvm_used = size - header_size; |
||||
tags->kvm_size = tags->kvm_used + CENSUS_MAX_TAG_KV_LEN; |
||||
tags->kvm = (char *)gpr_malloc(tags->kvm_size); |
||||
if (tag_header_size != TAG_HEADER_SIZE) { |
||||
// something new in the tag information. I don't understand it, so
|
||||
// don't copy it over.
|
||||
GPR_ASSERT(version != ENCODED_VERSION); |
||||
GPR_ASSERT(tag_header_size > TAG_HEADER_SIZE); |
||||
char *kvp = tags->kvm; |
||||
for (int i = 0; i < tags->ntags; i++) { |
||||
memcpy(kvp, buffer, TAG_HEADER_SIZE); |
||||
kvp += header_size; |
||||
struct raw_tag raw; |
||||
buffer = |
||||
decode_tag(&raw, (char *)buffer, tag_header_size - TAG_HEADER_SIZE); |
||||
memcpy(kvp, raw.key, (size_t)raw.key_len + raw.value_len); |
||||
kvp += raw.key_len + raw.value_len; |
||||
} |
||||
} else { |
||||
memcpy(tags->kvm, buffer, tags->kvm_used); |
||||
} |
||||
} |
||||
|
||||
census_context *census_context_decode(const char *buffer, size_t size) { |
||||
census_context *context = |
||||
(census_context *)gpr_malloc(sizeof(census_context)); |
||||
memset(&context->tags[LOCAL_TAGS], 0, sizeof(struct tag_set)); |
||||
if (buffer == NULL) { |
||||
memset(&context->tags[PROPAGATED_TAGS], 0, sizeof(struct tag_set)); |
||||
} else { |
||||
tag_set_decode(&context->tags[PROPAGATED_TAGS], buffer, size); |
||||
} |
||||
memset(&context->status, 0, sizeof(context->status)); |
||||
context->status.n_propagated_tags = context->tags[PROPAGATED_TAGS].ntags; |
||||
return context; |
||||
} |
@ -1,10 +0,0 @@ |
||||
Files generated for use by Census stats and trace recording subsystem. |
||||
|
||||
# Files |
||||
* census.pb.{h,c} - Generated from src/core/ext/census/census.proto, using the |
||||
script `tools/codegen/core/gen_nano_proto.sh src/proto/census/census.proto |
||||
$PWD/src/core/ext/census/gen src/core/ext/census/gen` |
||||
* trace_context.pb.{h,c} - Generated from |
||||
src/core/ext/census/trace_context.proto, using the script |
||||
`tools/codegen/core/gen_nano_proto.sh src/proto/census/trace_context.proto |
||||
$PWD/src/core/ext/census/gen src/core/ext/census/gen` |
@ -1,161 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016 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. |
||||
* |
||||
*/ |
||||
/* Automatically generated nanopb constant definitions */ |
||||
/* Generated by nanopb-0.3.5-dev */ |
||||
|
||||
#include "src/core/ext/census/gen/census.pb.h" |
||||
|
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
|
||||
|
||||
const pb_field_t google_census_Duration_fields[3] = { |
||||
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Duration, seconds, seconds, 0), |
||||
PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Duration, nanos, seconds, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Timestamp_fields[3] = { |
||||
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Timestamp, seconds, seconds, 0), |
||||
PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Timestamp, nanos, seconds, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Resource_fields[4] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Resource, name, name, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Resource, description, name, 0), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Resource, unit, description, &google_census_Resource_MeasurementUnit_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Resource_MeasurementUnit_fields[4] = { |
||||
PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Resource_MeasurementUnit, prefix, prefix, 0), |
||||
PB_FIELD( 2, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, numerator, prefix, 0), |
||||
PB_FIELD( 3, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, denominator, numerator, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_AggregationDescriptor_fields[4] = { |
||||
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_AggregationDescriptor, type, type, 0), |
||||
PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, bucket_boundaries, type, &google_census_AggregationDescriptor_BucketBoundaries_fields), |
||||
PB_ONEOF_FIELD(options, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, interval_boundaries, type, &google_census_AggregationDescriptor_IntervalBoundaries_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2] = { |
||||
PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_BucketBoundaries, bounds, bounds, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2] = { |
||||
PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_IntervalBoundaries, window_size, window_size, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Distribution_fields[5] = { |
||||
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Distribution, count, count, 0), |
||||
PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution, mean, count, 0), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Distribution, range, mean, &google_census_Distribution_Range_fields), |
||||
PB_FIELD( 4, INT64 , REPEATED, CALLBACK, OTHER, google_census_Distribution, bucket_count, range, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Distribution_Range_fields[3] = { |
||||
PB_FIELD( 1, DOUBLE , OPTIONAL, STATIC , FIRST, google_census_Distribution_Range, min, min, 0), |
||||
PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution_Range, max, min, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_IntervalStats_fields[2] = { |
||||
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_IntervalStats, window, window, &google_census_IntervalStats_Window_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_IntervalStats_Window_fields[4] = { |
||||
PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, google_census_IntervalStats_Window, window_size, window_size, &google_census_Duration_fields), |
||||
PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, count, window_size, 0), |
||||
PB_FIELD( 3, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, mean, count, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Tag_fields[3] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, google_census_Tag, key, key, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, google_census_Tag, value, key, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_View_fields[6] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_View, name, name, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, description, name, 0), |
||||
PB_FIELD( 3, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, resource_name, description, 0), |
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, resource_name, &google_census_AggregationDescriptor_fields), |
||||
PB_FIELD( 5, STRING , REPEATED, CALLBACK, OTHER, google_census_View, tag_key, aggregation, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Aggregation_fields[7] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Aggregation, name, name, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Aggregation, description, name, 0), |
||||
PB_ONEOF_FIELD(data, 3, UINT64 , ONEOF, STATIC , OTHER, google_census_Aggregation, count, description, 0), |
||||
PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields), |
||||
PB_ONEOF_FIELD(data, 5, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields), |
||||
PB_FIELD( 6, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Metric_fields[5] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, view_name, view_name, 0), |
||||
PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric, aggregation, view_name, &google_census_Aggregation_fields), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, start, aggregation, &google_census_Timestamp_fields), |
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, end, start, &google_census_Timestamp_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
|
||||
/* Check that field information fits in pb_field_t */ |
||||
#if !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_32BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in 8 or 16 bit |
||||
* field descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_Metric, aggregation) < 65536 && pb_membersize(google_census_Metric, start) < 65536 && pb_membersize(google_census_Metric, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric) |
||||
#endif |
||||
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_16BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in the default |
||||
* 8 bit descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_Metric, aggregation) < 256 && pb_membersize(google_census_Metric, start) < 256 && pb_membersize(google_census_Metric, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric) |
||||
#endif |
||||
|
||||
|
||||
/* On some platforms (such as AVR), double is really float.
|
||||
* These are not directly supported by nanopb, but see example_avr_double. |
||||
* To get rid of this error, remove any double fields from your .proto. |
||||
*/ |
||||
PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES) |
||||
|
@ -1,280 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016 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. |
||||
* |
||||
*/ |
||||
/* Automatically generated nanopb header */ |
||||
/* Generated by nanopb-0.3.5-dev */ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H |
||||
#define GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H |
||||
#include "third_party/nanopb/pb.h" |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Enum definitions */ |
||||
typedef enum _google_census_Resource_BasicUnit { |
||||
google_census_Resource_BasicUnit_UNKNOWN = 0, |
||||
google_census_Resource_BasicUnit_BITS = 1, |
||||
google_census_Resource_BasicUnit_BYTES = 2, |
||||
google_census_Resource_BasicUnit_SECS = 3, |
||||
google_census_Resource_BasicUnit_CORES = 4, |
||||
google_census_Resource_BasicUnit_MAX_UNITS = 5 |
||||
} google_census_Resource_BasicUnit; |
||||
|
||||
typedef enum _google_census_AggregationDescriptor_AggregationType { |
||||
google_census_AggregationDescriptor_AggregationType_UNKNOWN = 0, |
||||
google_census_AggregationDescriptor_AggregationType_COUNT = 1, |
||||
google_census_AggregationDescriptor_AggregationType_DISTRIBUTION = 2, |
||||
google_census_AggregationDescriptor_AggregationType_INTERVAL = 3 |
||||
} google_census_AggregationDescriptor_AggregationType; |
||||
|
||||
/* Struct definitions */ |
||||
typedef struct _google_census_AggregationDescriptor_BucketBoundaries { |
||||
pb_callback_t bounds; |
||||
} google_census_AggregationDescriptor_BucketBoundaries; |
||||
|
||||
typedef struct _google_census_AggregationDescriptor_IntervalBoundaries { |
||||
pb_callback_t window_size; |
||||
} google_census_AggregationDescriptor_IntervalBoundaries; |
||||
|
||||
typedef struct _google_census_IntervalStats { |
||||
pb_callback_t window; |
||||
} google_census_IntervalStats; |
||||
|
||||
typedef struct _google_census_AggregationDescriptor { |
||||
bool has_type; |
||||
google_census_AggregationDescriptor_AggregationType type; |
||||
pb_size_t which_options; |
||||
union { |
||||
google_census_AggregationDescriptor_BucketBoundaries bucket_boundaries; |
||||
google_census_AggregationDescriptor_IntervalBoundaries interval_boundaries; |
||||
} options; |
||||
} google_census_AggregationDescriptor; |
||||
|
||||
typedef struct _google_census_Distribution_Range { |
||||
bool has_min; |
||||
double min; |
||||
bool has_max; |
||||
double max; |
||||
} google_census_Distribution_Range; |
||||
|
||||
typedef struct _google_census_Duration { |
||||
bool has_seconds; |
||||
int64_t seconds; |
||||
bool has_nanos; |
||||
int32_t nanos; |
||||
} google_census_Duration; |
||||
|
||||
typedef struct _google_census_Resource_MeasurementUnit { |
||||
bool has_prefix; |
||||
int32_t prefix; |
||||
pb_callback_t numerator; |
||||
pb_callback_t denominator; |
||||
} google_census_Resource_MeasurementUnit; |
||||
|
||||
typedef struct _google_census_Tag { |
||||
bool has_key; |
||||
char key[255]; |
||||
bool has_value; |
||||
char value[255]; |
||||
} google_census_Tag; |
||||
|
||||
typedef struct _google_census_Timestamp { |
||||
bool has_seconds; |
||||
int64_t seconds; |
||||
bool has_nanos; |
||||
int32_t nanos; |
||||
} google_census_Timestamp; |
||||
|
||||
typedef struct _google_census_Distribution { |
||||
bool has_count; |
||||
int64_t count; |
||||
bool has_mean; |
||||
double mean; |
||||
bool has_range; |
||||
google_census_Distribution_Range range; |
||||
pb_callback_t bucket_count; |
||||
} google_census_Distribution; |
||||
|
||||
typedef struct _google_census_IntervalStats_Window { |
||||
bool has_window_size; |
||||
google_census_Duration window_size; |
||||
bool has_count; |
||||
int64_t count; |
||||
bool has_mean; |
||||
double mean; |
||||
} google_census_IntervalStats_Window; |
||||
|
||||
typedef struct _google_census_Metric { |
||||
pb_callback_t view_name; |
||||
pb_callback_t aggregation; |
||||
bool has_start; |
||||
google_census_Timestamp start; |
||||
bool has_end; |
||||
google_census_Timestamp end; |
||||
} google_census_Metric; |
||||
|
||||
typedef struct _google_census_Resource { |
||||
pb_callback_t name; |
||||
pb_callback_t description; |
||||
bool has_unit; |
||||
google_census_Resource_MeasurementUnit unit; |
||||
} google_census_Resource; |
||||
|
||||
typedef struct _google_census_View { |
||||
pb_callback_t name; |
||||
pb_callback_t description; |
||||
pb_callback_t resource_name; |
||||
bool has_aggregation; |
||||
google_census_AggregationDescriptor aggregation; |
||||
pb_callback_t tag_key; |
||||
} google_census_View; |
||||
|
||||
typedef struct _google_census_Aggregation { |
||||
pb_callback_t name; |
||||
pb_callback_t description; |
||||
pb_size_t which_data; |
||||
union { |
||||
uint64_t count; |
||||
google_census_Distribution distribution; |
||||
google_census_IntervalStats interval_stats; |
||||
} data; |
||||
pb_callback_t tag; |
||||
} google_census_Aggregation; |
||||
|
||||
/* Default values for struct fields */ |
||||
|
||||
/* Initializer values for message structs */ |
||||
#define google_census_Duration_init_default {false, 0, false, 0} |
||||
#define google_census_Timestamp_init_default {false, 0, false, 0} |
||||
#define google_census_Resource_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_default} |
||||
#define google_census_Resource_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_init_default {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}} |
||||
#define google_census_AggregationDescriptor_BucketBoundaries_init_default {{{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_init_default {{{NULL}, NULL}} |
||||
#define google_census_Distribution_init_default {false, 0, false, 0, false, google_census_Distribution_Range_init_default, {{NULL}, NULL}} |
||||
#define google_census_Distribution_Range_init_default {false, 0, false, 0} |
||||
#define google_census_IntervalStats_init_default {{{NULL}, NULL}} |
||||
#define google_census_IntervalStats_Window_init_default {false, google_census_Duration_init_default, false, 0, false, 0} |
||||
#define google_census_Tag_init_default {false, "", false, ""} |
||||
#define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}} |
||||
#define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}} |
||||
#define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default} |
||||
#define google_census_Duration_init_zero {false, 0, false, 0} |
||||
#define google_census_Timestamp_init_zero {false, 0, false, 0} |
||||
#define google_census_Resource_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_zero} |
||||
#define google_census_Resource_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_init_zero {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}} |
||||
#define google_census_AggregationDescriptor_BucketBoundaries_init_zero {{{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_init_zero {{{NULL}, NULL}} |
||||
#define google_census_Distribution_init_zero {false, 0, false, 0, false, google_census_Distribution_Range_init_zero, {{NULL}, NULL}} |
||||
#define google_census_Distribution_Range_init_zero {false, 0, false, 0} |
||||
#define google_census_IntervalStats_init_zero {{{NULL}, NULL}} |
||||
#define google_census_IntervalStats_Window_init_zero {false, google_census_Duration_init_zero, false, 0, false, 0} |
||||
#define google_census_Tag_init_zero {false, "", false, ""} |
||||
#define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}} |
||||
#define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}} |
||||
#define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero} |
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */ |
||||
#define google_census_AggregationDescriptor_BucketBoundaries_bounds_tag 1 |
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_window_size_tag 1 |
||||
#define google_census_IntervalStats_window_tag 1 |
||||
#define google_census_AggregationDescriptor_bucket_boundaries_tag 2 |
||||
|
||||
#define google_census_AggregationDescriptor_interval_boundaries_tag 3 |
||||
#define google_census_AggregationDescriptor_type_tag 1 |
||||
#define google_census_Distribution_Range_min_tag 1 |
||||
#define google_census_Distribution_Range_max_tag 2 |
||||
#define google_census_Duration_seconds_tag 1 |
||||
#define google_census_Duration_nanos_tag 2 |
||||
#define google_census_Resource_MeasurementUnit_prefix_tag 1 |
||||
#define google_census_Resource_MeasurementUnit_numerator_tag 2 |
||||
#define google_census_Resource_MeasurementUnit_denominator_tag 3 |
||||
#define google_census_Tag_key_tag 1 |
||||
#define google_census_Tag_value_tag 2 |
||||
#define google_census_Timestamp_seconds_tag 1 |
||||
#define google_census_Timestamp_nanos_tag 2 |
||||
#define google_census_Distribution_count_tag 1 |
||||
#define google_census_Distribution_mean_tag 2 |
||||
#define google_census_Distribution_range_tag 3 |
||||
#define google_census_Distribution_bucket_count_tag 4 |
||||
#define google_census_IntervalStats_Window_window_size_tag 1 |
||||
#define google_census_IntervalStats_Window_count_tag 2 |
||||
#define google_census_IntervalStats_Window_mean_tag 3 |
||||
#define google_census_Metric_view_name_tag 1 |
||||
#define google_census_Metric_aggregation_tag 2 |
||||
#define google_census_Metric_start_tag 3 |
||||
#define google_census_Metric_end_tag 4 |
||||
#define google_census_Resource_name_tag 1 |
||||
#define google_census_Resource_description_tag 2 |
||||
#define google_census_Resource_unit_tag 3 |
||||
#define google_census_View_name_tag 1 |
||||
#define google_census_View_description_tag 2 |
||||
#define google_census_View_resource_name_tag 3 |
||||
#define google_census_View_aggregation_tag 4 |
||||
#define google_census_View_tag_key_tag 5 |
||||
#define google_census_Aggregation_count_tag 3 |
||||
|
||||
#define google_census_Aggregation_distribution_tag 4 |
||||
|
||||
#define google_census_Aggregation_interval_stats_tag 5 |
||||
#define google_census_Aggregation_name_tag 1 |
||||
#define google_census_Aggregation_description_tag 2 |
||||
#define google_census_Aggregation_tag_tag 6 |
||||
|
||||
/* Struct field encoding specification for nanopb */ |
||||
extern const pb_field_t google_census_Duration_fields[3]; |
||||
extern const pb_field_t google_census_Timestamp_fields[3]; |
||||
extern const pb_field_t google_census_Resource_fields[4]; |
||||
extern const pb_field_t google_census_Resource_MeasurementUnit_fields[4]; |
||||
extern const pb_field_t google_census_AggregationDescriptor_fields[4]; |
||||
extern const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2]; |
||||
extern const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2]; |
||||
extern const pb_field_t google_census_Distribution_fields[5]; |
||||
extern const pb_field_t google_census_Distribution_Range_fields[3]; |
||||
extern const pb_field_t google_census_IntervalStats_fields[2]; |
||||
extern const pb_field_t google_census_IntervalStats_Window_fields[4]; |
||||
extern const pb_field_t google_census_Tag_fields[3]; |
||||
extern const pb_field_t google_census_View_fields[6]; |
||||
extern const pb_field_t google_census_Aggregation_fields[7]; |
||||
extern const pb_field_t google_census_Metric_fields[5]; |
||||
|
||||
/* Maximum encoded size of messages (where known) */ |
||||
#define google_census_Duration_size 22 |
||||
#define google_census_Timestamp_size 22 |
||||
#define google_census_Distribution_Range_size 18 |
||||
#define google_census_IntervalStats_Window_size 44 |
||||
#define google_census_Tag_size 516 |
||||
|
||||
/* Message IDs (where set with "msgid" option) */ |
||||
#ifdef PB_MSGID |
||||
|
||||
#define CENSUS_MESSAGES \ |
||||
|
||||
|
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H */ |
@ -1,39 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 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. |
||||
* |
||||
*/ |
||||
/* Automatically generated nanopb constant definitions */ |
||||
/* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */ |
||||
|
||||
#include "src/core/ext/census/gen/trace_context.pb.h" |
||||
|
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
|
||||
|
||||
const pb_field_t google_trace_TraceContext_fields[5] = { |
||||
PB_FIELD( 1, FIXED64 , OPTIONAL, STATIC , FIRST, google_trace_TraceContext, trace_id_hi, trace_id_hi, 0), |
||||
PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, trace_id_lo, trace_id_hi, 0), |
||||
PB_FIELD( 3, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_id, trace_id_lo, 0), |
||||
PB_FIELD( 4, FIXED32 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_options, span_id, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
|
||||
/* @@protoc_insertion_point(eof) */ |
@ -1,78 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 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. |
||||
* |
||||
*/ |
||||
/* Automatically generated nanopb header */ |
||||
/* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H |
||||
#define GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H |
||||
#include "third_party/nanopb/pb.h" |
||||
|
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Struct definitions */ |
||||
typedef struct _google_trace_TraceContext { |
||||
bool has_trace_id_hi; |
||||
uint64_t trace_id_hi; |
||||
bool has_trace_id_lo; |
||||
uint64_t trace_id_lo; |
||||
bool has_span_id; |
||||
uint64_t span_id; |
||||
bool has_span_options; |
||||
uint32_t span_options; |
||||
/* @@protoc_insertion_point(struct:google_trace_TraceContext) */ |
||||
} google_trace_TraceContext; |
||||
|
||||
/* Default values for struct fields */ |
||||
|
||||
/* Initializer values for message structs */ |
||||
#define google_trace_TraceContext_init_default {false, 0, false, 0, false, 0, false, 0} |
||||
#define google_trace_TraceContext_init_zero {false, 0, false, 0, false, 0, false, 0} |
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */ |
||||
#define google_trace_TraceContext_trace_id_hi_tag 1 |
||||
#define google_trace_TraceContext_trace_id_lo_tag 2 |
||||
#define google_trace_TraceContext_span_id_tag 3 |
||||
#define google_trace_TraceContext_span_options_tag 4 |
||||
|
||||
/* Struct field encoding specification for nanopb */ |
||||
extern const pb_field_t google_trace_TraceContext_fields[5]; |
||||
|
||||
/* Maximum encoded size of messages (where known) */ |
||||
#define google_trace_TraceContext_size 32 |
||||
|
||||
/* Message IDs (where set with "msgid" option) */ |
||||
#ifdef PB_MSGID |
||||
|
||||
#define TRACE_CONTEXT_MESSAGES \ |
||||
|
||||
|
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
/* @@protoc_insertion_point(eof) */ |
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H */ |
@ -1,196 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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 "src/core/ext/census/grpc_filter.h" |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/census.h> |
||||
#include <grpc/slice.h> |
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/ext/census/census_interface.h" |
||||
#include "src/core/ext/census/census_rpc_stats.h" |
||||
#include "src/core/lib/channel/channel_stack.h" |
||||
#include "src/core/lib/profiling/timers.h" |
||||
#include "src/core/lib/transport/static_metadata.h" |
||||
|
||||
typedef struct call_data { |
||||
census_op_id op_id; |
||||
census_context *ctxt; |
||||
gpr_timespec start_ts; |
||||
int error; |
||||
|
||||
/* recv callback */ |
||||
grpc_metadata_batch *recv_initial_metadata; |
||||
grpc_closure *on_done_recv; |
||||
grpc_closure finish_recv; |
||||
} call_data; |
||||
|
||||
typedef struct channel_data { uint8_t unused; } channel_data; |
||||
|
||||
static void extract_and_annotate_method_tag(grpc_metadata_batch *md, |
||||
call_data *calld, |
||||
channel_data *chand) { |
||||
grpc_linked_mdelem *m; |
||||
for (m = md->list.head; m != NULL; m = m->next) { |
||||
if (grpc_slice_eq(GRPC_MDKEY(m->md), GRPC_MDSTR_PATH)) { |
||||
/* Add method tag here */ |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void client_mutate_op(grpc_call_element *elem, |
||||
grpc_transport_stream_op_batch *op) { |
||||
call_data *calld = (call_data *)elem->call_data; |
||||
channel_data *chand = (channel_data *)elem->channel_data; |
||||
if (op->send_initial_metadata) { |
||||
extract_and_annotate_method_tag( |
||||
op->payload->send_initial_metadata.send_initial_metadata, calld, chand); |
||||
} |
||||
} |
||||
|
||||
static void client_start_transport_op(grpc_exec_ctx *exec_ctx, |
||||
grpc_call_element *elem, |
||||
grpc_transport_stream_op_batch *op) { |
||||
client_mutate_op(elem, op); |
||||
grpc_call_next_op(exec_ctx, elem, op); |
||||
} |
||||
|
||||
static void server_on_done_recv(grpc_exec_ctx *exec_ctx, void *ptr, |
||||
grpc_error *error) { |
||||
GPR_TIMER_BEGIN("census-server:server_on_done_recv", 0); |
||||
grpc_call_element *elem = (grpc_call_element *)ptr; |
||||
call_data *calld = (call_data *)elem->call_data; |
||||
channel_data *chand = (channel_data *)elem->channel_data; |
||||
if (error == GRPC_ERROR_NONE) { |
||||
extract_and_annotate_method_tag(calld->recv_initial_metadata, calld, chand); |
||||
} |
||||
calld->on_done_recv->cb(exec_ctx, calld->on_done_recv->cb_arg, error); |
||||
GPR_TIMER_END("census-server:server_on_done_recv", 0); |
||||
} |
||||
|
||||
static void server_mutate_op(grpc_call_element *elem, |
||||
grpc_transport_stream_op_batch *op) { |
||||
call_data *calld = (call_data *)elem->call_data; |
||||
if (op->recv_initial_metadata) { |
||||
/* substitute our callback for the op callback */ |
||||
calld->recv_initial_metadata = |
||||
op->payload->recv_initial_metadata.recv_initial_metadata; |
||||
calld->on_done_recv = |
||||
op->payload->recv_initial_metadata.recv_initial_metadata_ready; |
||||
op->payload->recv_initial_metadata.recv_initial_metadata_ready = |
||||
&calld->finish_recv; |
||||
} |
||||
} |
||||
|
||||
static void server_start_transport_op(grpc_exec_ctx *exec_ctx, |
||||
grpc_call_element *elem, |
||||
grpc_transport_stream_op_batch *op) { |
||||
/* TODO(ctiller): this code fails. I don't know why. I expect it's
|
||||
incomplete, and someone should look at it soon. |
||||
|
||||
call_data *calld = elem->call_data; |
||||
GPR_ASSERT((calld->op_id.upper != 0) || (calld->op_id.lower != 0)); */ |
||||
server_mutate_op(elem, op); |
||||
grpc_call_next_op(exec_ctx, elem, op); |
||||
} |
||||
|
||||
static grpc_error *client_init_call_elem(grpc_exec_ctx *exec_ctx, |
||||
grpc_call_element *elem, |
||||
const grpc_call_element_args *args) { |
||||
call_data *d = (call_data *)elem->call_data; |
||||
GPR_ASSERT(d != NULL); |
||||
memset(d, 0, sizeof(*d)); |
||||
d->start_ts = args->start_time; |
||||
return GRPC_ERROR_NONE; |
||||
} |
||||
|
||||
static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx, |
||||
grpc_call_element *elem, |
||||
const grpc_call_final_info *final_info, |
||||
grpc_closure *ignored) { |
||||
call_data *d = (call_data *)elem->call_data; |
||||
GPR_ASSERT(d != NULL); |
||||
/* TODO(hongyu): record rpc client stats and census_rpc_end_op here */ |
||||
} |
||||
|
||||
static grpc_error *server_init_call_elem(grpc_exec_ctx *exec_ctx, |
||||
grpc_call_element *elem, |
||||
const grpc_call_element_args *args) { |
||||
call_data *d = (call_data *)elem->call_data; |
||||
GPR_ASSERT(d != NULL); |
||||
memset(d, 0, sizeof(*d)); |
||||
d->start_ts = args->start_time; |
||||
/* TODO(hongyu): call census_tracing_start_op here. */ |
||||
GRPC_CLOSURE_INIT(&d->finish_recv, server_on_done_recv, elem, |
||||
grpc_schedule_on_exec_ctx); |
||||
return GRPC_ERROR_NONE; |
||||
} |
||||
|
||||
static void server_destroy_call_elem(grpc_exec_ctx *exec_ctx, |
||||
grpc_call_element *elem, |
||||
const grpc_call_final_info *final_info, |
||||
grpc_closure *ignored) { |
||||
call_data *d = (call_data *)elem->call_data; |
||||
GPR_ASSERT(d != NULL); |
||||
/* TODO(hongyu): record rpc server stats and census_tracing_end_op here */ |
||||
} |
||||
|
||||
static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, |
||||
grpc_channel_element *elem, |
||||
grpc_channel_element_args *args) { |
||||
channel_data *chand = (channel_data *)elem->channel_data; |
||||
GPR_ASSERT(chand != NULL); |
||||
return GRPC_ERROR_NONE; |
||||
} |
||||
|
||||
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, |
||||
grpc_channel_element *elem) { |
||||
channel_data *chand = (channel_data *)elem->channel_data; |
||||
GPR_ASSERT(chand != NULL); |
||||
} |
||||
|
||||
const grpc_channel_filter grpc_client_census_filter = { |
||||
client_start_transport_op, |
||||
grpc_channel_next_op, |
||||
sizeof(call_data), |
||||
client_init_call_elem, |
||||
grpc_call_stack_ignore_set_pollset_or_pollset_set, |
||||
client_destroy_call_elem, |
||||
sizeof(channel_data), |
||||
init_channel_elem, |
||||
destroy_channel_elem, |
||||
grpc_channel_next_get_info, |
||||
"census-client"}; |
||||
|
||||
const grpc_channel_filter grpc_server_census_filter = { |
||||
server_start_transport_op, |
||||
grpc_channel_next_op, |
||||
sizeof(call_data), |
||||
server_init_call_elem, |
||||
grpc_call_stack_ignore_set_pollset_or_pollset_set, |
||||
server_destroy_call_elem, |
||||
sizeof(channel_data), |
||||
init_channel_elem, |
||||
destroy_channel_elem, |
||||
grpc_channel_next_get_info, |
||||
"census-server"}; |
@ -1,70 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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 <grpc/support/port_platform.h> |
||||
|
||||
#include <limits.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/census.h> |
||||
|
||||
#include "src/core/ext/census/grpc_filter.h" |
||||
#include "src/core/lib/channel/channel_stack_builder.h" |
||||
#include "src/core/lib/surface/channel_init.h" |
||||
|
||||
static bool is_census_enabled(const grpc_channel_args *a) { |
||||
size_t i; |
||||
if (a == NULL) return 0; |
||||
for (i = 0; i < a->num_args; i++) { |
||||
if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_CENSUS)) { |
||||
return a->args[i].value.integer != 0 && census_enabled(); |
||||
} |
||||
} |
||||
return census_enabled() && !grpc_channel_args_want_minimal_stack(a); |
||||
} |
||||
|
||||
static bool maybe_add_census_filter(grpc_exec_ctx *exec_ctx, |
||||
grpc_channel_stack_builder *builder, |
||||
void *arg) { |
||||
const grpc_channel_args *args = |
||||
grpc_channel_stack_builder_get_channel_arguments(builder); |
||||
if (is_census_enabled(args)) { |
||||
return grpc_channel_stack_builder_prepend_filter( |
||||
builder, (const grpc_channel_filter *)arg, NULL, NULL); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
extern "C" void census_grpc_plugin_init(void) { |
||||
/* Only initialize census if no one else has and some features are
|
||||
* available. */ |
||||
if (census_enabled() == CENSUS_FEATURE_NONE && |
||||
census_supported() != CENSUS_FEATURE_NONE) { |
||||
if (census_initialize(census_supported())) { /* enable all features. */ |
||||
gpr_log(GPR_ERROR, "Could not initialize census."); |
||||
} |
||||
} |
||||
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, |
||||
maybe_add_census_filter, |
||||
(void *)&grpc_client_census_filter); |
||||
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, |
||||
maybe_add_census_filter, |
||||
(void *)&grpc_server_census_filter); |
||||
} |
||||
|
||||
extern "C" void census_grpc_plugin_shutdown(void) { census_shutdown(); } |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue