passthru_endpoint.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. *
  3. * Copyright 2016 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef PASSTHRU_ENDPOINT_H
  19. #define PASSTHRU_ENDPOINT_H
  20. #include <grpc/support/atm.h>
  21. #include "src/core/lib/iomgr/endpoint.h"
  22. /* The struct is refcounted, always use grpc_passthru_endpoint_stats_create and
  23. * grpc_passthru_endpoint_stats_destroy, rather then embedding it in your
  24. * objects by value. */
  25. typedef struct {
  26. gpr_refcount refs;
  27. gpr_atm num_writes;
  28. } grpc_passthru_endpoint_stats;
  29. typedef struct {
  30. uint64_t wait_ms;
  31. uint64_t add_n_writable_bytes;
  32. uint64_t add_n_readable_bytes;
  33. } grpc_passthru_endpoint_channel_action;
  34. void grpc_passthru_endpoint_create(grpc_endpoint** client,
  35. grpc_endpoint** server,
  36. grpc_passthru_endpoint_stats* stats,
  37. bool simulate_channel_actions = false);
  38. grpc_passthru_endpoint_stats* grpc_passthru_endpoint_stats_create();
  39. void grpc_passthru_endpoint_stats_destroy(grpc_passthru_endpoint_stats* stats);
  40. void start_scheduling_grpc_passthru_endpoint_channel_effects(
  41. grpc_endpoint* ep,
  42. const std::vector<grpc_passthru_endpoint_channel_action>& actions);
  43. #endif // PASSTHRU_ENDPOINT_H