aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/neh/factory.h
blob: c3ea3eed052b92c515331ef2fa0cfcc090b0d4d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include "neh.h"
#include "rpc.h"

namespace NNeh {
    struct TParsedLocation;

    class IProtocol {
    public:
        virtual ~IProtocol() {
        }
        virtual IRequesterRef CreateRequester(IOnRequest* cb, const TParsedLocation& loc) = 0;
        virtual THandleRef ScheduleRequest(const TMessage& msg, IOnRecv* fallback, TServiceStatRef&) = 0;
        virtual TStringBuf Scheme() const noexcept = 0;
        virtual bool SetOption(TStringBuf name, TStringBuf value) {
            Y_UNUSED(name);
            Y_UNUSED(value);
            return false;
        }
    };

    class IProtocolFactory {
    public:
        virtual IProtocol* Protocol(const TStringBuf& scheme) = 0;
        virtual void Register(IProtocol* proto) = 0;
        virtual ~IProtocolFactory() {
        }
    };

    void SetGlobalFactory(IProtocolFactory* factory);
    IProtocolFactory* ProtocolFactory();
}