session_config.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "codegen.h"
  3. #include "defs.h"
  4. #include <library/cpp/getopt/last_getopt.h>
  5. #include <util/generic/string.h>
  6. namespace NBus {
  7. #define BUS_SESSION_CONFIG_MAP(XX, comma) \
  8. XX(Name, TString, "") \
  9. comma \
  10. XX(NumRetries, int, 0) comma \
  11. XX(RetryInterval, int, 1000) comma \
  12. XX(ReconnectWhenIdle, bool, false) comma \
  13. XX(MaxInFlight, i64, 1000) comma \
  14. XX(PerConnectionMaxInFlight, unsigned, 0) comma \
  15. XX(PerConnectionMaxInFlightBySize, unsigned, 0) comma \
  16. XX(MaxInFlightBySize, i64, -1) comma \
  17. XX(TotalTimeout, i64, 0) comma \
  18. XX(SendTimeout, i64, 0) comma \
  19. XX(ConnectTimeout, i64, 0) comma \
  20. XX(DefaultBufferSize, size_t, 10 * 1024) comma \
  21. XX(MaxBufferSize, size_t, 1024 * 1024) comma \
  22. XX(SocketRecvBufferSize, unsigned, 0) comma \
  23. XX(SocketSendBufferSize, unsigned, 0) comma \
  24. XX(SocketToS, int, -1) comma \
  25. XX(SendThreshold, size_t, 10 * 1024) comma \
  26. XX(Cork, TDuration, TDuration::Zero()) comma \
  27. XX(MaxMessageSize, unsigned, 26 << 20) comma \
  28. XX(TcpNoDelay, bool, false) comma \
  29. XX(TcpCork, bool, false) comma \
  30. XX(ExecuteOnMessageInWorkerPool, bool, true) comma \
  31. XX(ExecuteOnReplyInWorkerPool, bool, true) comma \
  32. XX(ReusePort, bool, false) comma \
  33. XX(ListenPort, unsigned, 0) /* TODO: server only */
  34. ////////////////////////////////////////////////////////////////////
  35. /// \brief Configuration for client and server session
  36. struct TBusSessionConfig {
  37. BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_GEN, )
  38. struct TSecret {
  39. TDuration TimeoutPeriod;
  40. TDuration StatusFlushPeriod;
  41. TSecret();
  42. };
  43. // secret options are available, but you shouldn't probably use them
  44. TSecret Secret;
  45. /// initialized with default settings
  46. TBusSessionConfig();
  47. TString PrintToString() const;
  48. void ConfigureLastGetopt(NLastGetopt::TOpts&, const TString& prefix = "mb-");
  49. };
  50. using TBusClientSessionConfig = TBusSessionConfig;
  51. using TBusServerSessionConfig = TBusSessionConfig;
  52. } // NBus