interface.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #pragma once
  2. #include <unistd.h>
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // This is a plain C version of an interface described in yt/yql/plugin/plugin.h.
  5. // All strings without separate length field are assumed to be null-terminated.
  6. ////////////////////////////////////////////////////////////////////////////////
  7. // NB(mpereskokova): don't forget to update min_required_abi_version at yt/yql/agent/config.cpp and abi_version in yt/yql/plugin/dynamic/impl.cpp during breaking changes
  8. using TFuncBridgeGetAbiVersion = ssize_t();
  9. ////////////////////////////////////////////////////////////////////////////////
  10. struct TBridgeYqlPluginOptions
  11. {
  12. const char* SingletonsConfig = nullptr;
  13. ssize_t SingletonsConfigLength = 0;
  14. const char* GatewayConfig = nullptr;
  15. size_t GatewayConfigLength = 0;
  16. const char* FileStorageConfig = nullptr;
  17. size_t FileStorageConfigLength = 0;
  18. const char* OperationAttributes = nullptr;
  19. size_t OperationAttributesLength = 0;
  20. const char* YTTokenPath = nullptr;
  21. // TODO(max42): passing C++ objects across shared libraries is incredibly
  22. // fragile. This is a temporary mean until we come up with something more
  23. // convenient; get rid of this ASAP.
  24. using TLogBackendHolder = void;
  25. TLogBackendHolder* LogBackend = nullptr;
  26. };
  27. // Opaque type representing a YQL plugin.
  28. using TBridgeYqlPlugin = void;
  29. using TFuncBridgeCreateYqlPlugin = TBridgeYqlPlugin*(const TBridgeYqlPluginOptions* options);
  30. using TFuncBridgeFreeYqlPlugin = void(TBridgeYqlPlugin* plugin);
  31. ////////////////////////////////////////////////////////////////////////////////
  32. // TODO(max42): consider making structure an opaque type with accessors a-la
  33. // const char* BridgeGetYsonResult(const TBridgeQueryResult*). This would remove the need
  34. // to manually free string data.
  35. struct TBridgeQueryResult
  36. {
  37. const char* YsonResult = nullptr;
  38. ssize_t YsonResultLength = 0;
  39. const char* Plan = nullptr;
  40. ssize_t PlanLength = 0;
  41. const char* Statistics = nullptr;
  42. ssize_t StatisticsLength = 0;
  43. const char* Progress = nullptr;
  44. ssize_t ProgressLength = 0;
  45. const char* TaskInfo = nullptr;
  46. ssize_t TaskInfoLength = 0;
  47. const char* YsonError = nullptr;
  48. ssize_t YsonErrorLength = 0;
  49. };
  50. enum EQueryFileContentType
  51. {
  52. RawInlineData,
  53. Url,
  54. };
  55. struct TBridgeQueryFile
  56. {
  57. const char* Name = nullptr;
  58. size_t NameLength = 0;
  59. const char* Content = nullptr;
  60. size_t ContentLength = 0;
  61. EQueryFileContentType Type;
  62. };
  63. using TFuncBridgeFreeQueryResult = void(TBridgeQueryResult* result);
  64. using TFuncBridgeRun = TBridgeQueryResult*(TBridgeYqlPlugin* plugin, const char* queryId, const char* impersonationUser, const char* queryText, const char* settings, const TBridgeQueryFile* files, int fileCount);
  65. using TFuncBridgeGetProgress = TBridgeQueryResult*(TBridgeYqlPlugin* plugin, const char* queryId);
  66. using TFuncBridgeAbort = void(TBridgeYqlPlugin* plugin, const char* queryId);
  67. ////////////////////////////////////////////////////////////////////////////////
  68. #define FOR_EACH_BRIDGE_INTERFACE_FUNCTION(XX) \
  69. XX(BridgeCreateYqlPlugin) \
  70. XX(BridgeFreeYqlPlugin) \
  71. XX(BridgeFreeQueryResult) \
  72. XX(BridgeRun) \
  73. XX(BridgeGetProgress) \
  74. XX(BridgeGetAbiVersion)
  75. ////////////////////////////////////////////////////////////////////////////////