factory.h 910 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include "neh.h"
  3. #include "rpc.h"
  4. namespace NNeh {
  5. struct TParsedLocation;
  6. class IProtocol {
  7. public:
  8. virtual ~IProtocol() {
  9. }
  10. virtual IRequesterRef CreateRequester(IOnRequest* cb, const TParsedLocation& loc) = 0;
  11. virtual THandleRef ScheduleRequest(const TMessage& msg, IOnRecv* fallback, TServiceStatRef&) = 0;
  12. virtual TStringBuf Scheme() const noexcept = 0;
  13. virtual bool SetOption(TStringBuf name, TStringBuf value) {
  14. Y_UNUSED(name);
  15. Y_UNUSED(value);
  16. return false;
  17. }
  18. };
  19. class IProtocolFactory {
  20. public:
  21. virtual IProtocol* Protocol(const TStringBuf& scheme) = 0;
  22. virtual void Register(IProtocol* proto) = 0;
  23. virtual ~IProtocolFactory() {
  24. }
  25. };
  26. void SetGlobalFactory(IProtocolFactory* factory);
  27. IProtocolFactory* ProtocolFactory();
  28. }