31
31
* File Description:
32
32
* Private API to define server iterator structure.
36
#include "ncbi_server_infop.h"
37
#include <connect/ncbi_service.h>
45
/* Table of iterator "virtual functions"
48
void (*Reset)(SERV_ITER iter);
49
SSERV_Info* (*GetNextInfo)(SERV_ITER iter, HOST_INFO* host_info);
50
int/*bool*/ (*Update)(SERV_ITER iter, TNCBI_Time now, const char* text);
51
int/*bool*/ (*Penalize)(SERV_ITER iter, double penalty);
52
void (*Close)(SERV_ITER iter);
59
struct SSERV_IterTag {
60
const char* service; /* requested service name */
61
TSERV_Type types; /* requested server type(s) */
62
unsigned int preferred_host; /* preferred host to select, network b.o. */
63
double preference; /* range [0..100] %% */
64
SSERV_Info** skip; /* servers to skip */
65
size_t n_skip; /* number of servers in the array */
66
size_t n_max_skip; /* number of allocated slots in the array */
67
SSERV_Info* last; /* last server info taken out */
69
const SSERV_VTable* op; /* table of virtual functions */
71
void* data; /* private data field */
72
int/*bool*/ external; /* true for mapping of external requests */
76
/* Modified 'fast track' routine for one-shot obtaining of a service info.
77
* Please see <connect/ncbi_service.h> for explanations [SERV_GetInfoEx()].
78
* For now, this call is to exclusively support MYgethostbyname() replacement
79
* of standard gethostbyname() libcall in apache Web daemon (see in daemons/).
81
* NOTE: Preference 0.0 does not prohibit the preferred_host to be selected;
82
* nor preference 100.0 ultimately opts for the preferred_host; rather,
83
* the preference is considered as an estimate for the selection
84
* probability when all other conditions for favoring the host are
85
* optimal, i.e. preference 0.0 actually means not to favor the preferred
86
* host at all, while 100.0 means to opt for that as much as possible.
88
SSERV_Info* SERV_GetInfoP
89
(const char* service, /* service name */
90
TSERV_Type types, /* mask of type(s) of servers requested */
91
unsigned int preferred_host,/* preferred host to use service on, nbo */
92
double preference, /* [0=min..100=max] preference in %% */
93
int/*bool*/ external /* whether mapping is not local to NCBI */
96
/* same as the above but creates an iterator to get services one by one */
100
unsigned int preferred_host,
106
/* Private interface: update mapper information from the given text
107
* (<CR><LF> separated lines, usually taken from HTTP header).
109
int/*bool*/ SERV_Update(SERV_ITER iter, const char* text);
112
/* Private interface: print and return the HTTP-compliant header portion
113
* (<CR><LF> separated lines, including the last line) out of the information
114
* contained in the iterator; to be used in mapping requests to DISPD.
115
* Return value must be 'free'd.
117
char* SERV_PrintEx(SERV_ITER iter, const SConnNetInfo* referrer);
119
#define SERV_Print(iter) SERV_PrintEx(iter, 0)
122
/* Get name of underlying service mapper.
124
const char* SERV_MapperName(SERV_ITER iter);
127
/* Get final service name, using CONN_SERVICE_NAME_service environment
128
* variable, then (if not found) registry section [service] and a key
129
* CONN_SERVICE_NAME. Return resulting name (perhaps, an exact copy of
130
* "service" if no override name was found in environment/registry), which
131
* is to be freed by a caller when no longer needed. Return NULL on error.
132
* NOTE: This procedure does not detect cyclical redefinitions.
134
char* SERV_ServiceName(const char* service);
137
/* Get configuration file name. Returned '\0'-terminated string
138
* is to be free()'d by a caller when no longer needed.
139
* Return NULL if no configuration file name available.
141
char* SERV_GetConfig(void);
144
/* Given the status gap and wanted preference, calculate
145
* acceptable stretch for the gap (the number of candidates is n).
147
double SERV_Preference(double pref, double gap, unsigned int n);
34
156
* --------------------------------------------------------------------------
35
157
* $Log: ncbi_servicep.h,v $
158
* Revision 6.25 2004/08/19 15:48:04 lavr
159
* SERV_ITER::type renamed into SERV_ITER::types to reflect its bitmask nature
161
* Revision 6.24 2004/07/01 16:27:55 lavr
164
* Revision 6.23 2003/06/26 15:19:56 lavr
165
* Additional parameter "external" for SERV_{Open|GetInfo}P()
167
* Revision 6.22 2003/06/09 19:53:11 lavr
170
* Revision 6.21 2003/03/07 22:21:55 lavr
171
* Explain what is "preference" for SERV_GetInfoP()
173
* Revision 6.20 2003/02/28 14:49:09 lavr
174
* SERV_Preference(): redeclare last argument 'unsigned'
176
* Revision 6.19 2003/02/13 21:37:28 lavr
177
* Comment SERV_Preference(), change last argument
179
* Revision 6.18 2003/01/31 21:19:41 lavr
182
* Revision 6.17 2002/10/28 20:16:00 lavr
183
* Take advantage of host info API
185
* Revision 6.16 2002/10/11 19:48:25 lavr
187
* const dropped in return value of SERV_ServiceName()
189
* Revision 6.15 2002/09/19 18:08:43 lavr
190
* Header file guard macro changed; log moved to end
192
* Revision 6.14 2002/05/06 19:17:04 lavr
193
* +SERV_ServiceName() - translation of service name
36
195
* Revision 6.13 2001/09/28 20:50:41 lavr
37
196
* Update VT method changed - now called on per-line basis
80
239
* ==========================================================================
83
#include <connect/ncbi_service.h>
90
/* Table of iterator "virtual functions"
93
void (*Reset)(SERV_ITER iter);
94
SSERV_Info* (*GetNextInfo)(SERV_ITER iter, char** env);
95
int/*bool*/ (*Update)(SERV_ITER iter, TNCBI_Time now, const char* text);
96
int/*bool*/ (*Penalize)(SERV_ITER iter, double penalty);
97
void (*Close)(SERV_ITER iter);
102
/* Iterator structure
104
struct SSERV_IterTag {
105
const char* service; /* requested service name */
106
TSERV_Type type; /* requested server type(s) */
107
unsigned int preferred_host; /* preferred host to select, network b.o. */
108
SSERV_Info** skip; /* servers to skip */
109
size_t n_skip; /* number of servers in the array */
110
size_t n_max_skip; /* number of allocated slots in the array */
111
SSERV_Info* last; /* last server info taken out */
113
const SSERV_VTable* op; /* table of virtual functions */
115
void* data; /* private data field */
119
/* Private interface: update mapper information from the given text
120
* (<CR><LF> separated lines, usually taken from HTTP header).
122
int/*bool*/ SERV_Update(SERV_ITER iter, const char* text);
125
/* Private interface: print and return the HTTP-compliant header portion
126
* (<CR><LF> separated lines, including the last line) out of the information
127
* contained in the iterator; to be used in mapping requests to DISPD.
128
* Return value must be 'free'd.
130
char* SERV_Print(SERV_ITER iter);
133
/* Get name of underlying service mapper.
135
const char* SERV_MapperName(SERV_ITER iter);
142
#endif /* NCBI_SERVICEP__H */
242
#endif /* CONNECT___NCBI_SERVICEP__H */