New server facility scheme.
[yazpp-moved-to-github.git] / include / yaz++ / yaz-proxy.h
1 /*
2  * Copyright (c) 1998-2000, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Id: yaz-proxy.h,v 1.3 2001-03-26 14:43:49 adam Exp $
6  */
7
8 #include <yaz++/yaz-z-assoc.h>
9 #include <yaz++/yaz-z-query.h>
10
11 class Yaz_Proxy;
12
13 /// Private class
14 class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc {
15     friend Yaz_Proxy;
16     Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable);
17     ~Yaz_ProxyClient();
18     void recv_Z_PDU(Z_APDU *apdu);
19     IYaz_PDU_Observer* sessionNotify
20         (IYaz_PDU_Observable *the_PDU_Observable, int fd);
21     void shutdown();
22     Yaz_Proxy *m_server;
23     void failNotify();
24     void timeoutNotify();
25     void connectNotify();
26     char m_cookie[32];
27     Yaz_ProxyClient *m_next;
28     Yaz_ProxyClient **m_prev;
29     int m_init_flag;
30     Yaz_Z_Query *m_last_query;
31     int m_last_resultCount;
32     int m_sr_transform;
33     int m_seqno;
34     int m_waiting;
35 };
36
37 /// Information Retrieval Proxy Server.
38 class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
39  private:
40     char *get_cookie(Z_OtherInformation **otherInfo);
41     char *get_proxy(Z_OtherInformation **otherInfo);
42     Yaz_ProxyClient *get_client(Z_APDU *apdu);
43     Z_APDU *result_set_optimize(Z_APDU *apdu);
44     void shutdown();
45     
46     Yaz_ProxyClient *m_client;
47     IYaz_PDU_Observable *m_PDU_Observable;
48     Yaz_ProxyClient *m_clientPool;
49     Yaz_Proxy *m_parent;
50     int m_seqno;
51     int m_max_clients;
52     int m_keepalive;
53     char *m_proxyTarget;
54     long m_seed;
55  public:
56     Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable);
57     ~Yaz_Proxy();
58     void recv_Z_PDU(Z_APDU *apdu);
59     IYaz_PDU_Observer* sessionNotify
60         (IYaz_PDU_Observable *the_PDU_Observable, int fd);
61     void failNotify();
62     void timeoutNotify();
63     void connectNotify();
64     void set_proxyTarget(const char *target);
65     char *get_proxyTarget() { return m_proxyTarget; };
66     void set_max_clients(int m) { m_max_clients = m; };
67 };
68