Fix: proxy doesn't cache searches/result sets when errors occur.
[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.5 2002-01-14 12:01:27 adam Exp $
6  */
7
8 #include <yaz++/yaz-z-assoc.h>
9 #include <yaz++/yaz-z-query.h>
10 #include <yaz++/yaz-z-databases.h>
11
12 class Yaz_Proxy;
13
14 /// Private class
15 class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc {
16     friend Yaz_Proxy;
17     Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable);
18     ~Yaz_ProxyClient();
19     void recv_Z_PDU(Z_APDU *apdu);
20     IYaz_PDU_Observer* sessionNotify
21         (IYaz_PDU_Observable *the_PDU_Observable, int fd);
22     void shutdown();
23     Yaz_Proxy *m_server;
24     void failNotify();
25     void timeoutNotify();
26     void connectNotify();
27     char m_cookie[32];
28     Yaz_ProxyClient *m_next;
29     Yaz_ProxyClient **m_prev;
30     int m_init_flag;
31     Yaz_Z_Query *m_last_query;
32     Yaz_Z_Databases m_last_databases;
33     int m_last_ok;
34     int m_last_resultCount;
35     int m_sr_transform;
36     int m_seqno;
37     int m_waiting;
38 };
39
40 /// Information Retrieval Proxy Server.
41 class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
42  private:
43     char *get_cookie(Z_OtherInformation **otherInfo);
44     char *get_proxy(Z_OtherInformation **otherInfo);
45     Yaz_ProxyClient *get_client(Z_APDU *apdu);
46     Z_APDU *result_set_optimize(Z_APDU *apdu);
47     void shutdown();
48     
49     Yaz_ProxyClient *m_client;
50     IYaz_PDU_Observable *m_PDU_Observable;
51     Yaz_ProxyClient *m_clientPool;
52     Yaz_Proxy *m_parent;
53     int m_seqno;
54     int m_max_clients;
55     int m_keepalive;
56     char *m_proxyTarget;
57     char *m_proxy_authentication;
58     long m_seed;
59     char *m_optimize;
60  public:
61     Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable);
62     ~Yaz_Proxy();
63     void recv_Z_PDU(Z_APDU *apdu);
64     IYaz_PDU_Observer* sessionNotify
65         (IYaz_PDU_Observable *the_PDU_Observable, int fd);
66     void failNotify();
67     void timeoutNotify();
68     void connectNotify();
69     const char *option(const char *name, const char *value);
70     void set_proxy_target(const char *target);
71     void set_proxy_authentication (const char *auth);
72     char *get_proxy_target() { return m_proxyTarget; };
73     void set_max_clients(int m) { m_max_clients = m; };
74 };
75