This repository has been archived by the owner on Feb 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 326
/
Copy pathread_preference.h
71 lines (56 loc) · 2.66 KB
/
read_preference.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Copyright 2009-2014 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __MCON_READ_PREFERENCE_H__
#define __MCON_READ_PREFERENCE_H__
#include "types.h"
#include "collection.h"
#define MONGO_RP_FIRST 0x00
/* The order of these is significant. Do not change! */
#define MONGO_RP_PRIMARY 0x00
#define MONGO_RP_PRIMARY_PREFERRED 0x01
#define MONGO_RP_SECONDARY 0x02
#define MONGO_RP_SECONDARY_PREFERRED 0x03
#define MONGO_RP_NEAREST 0x04
#define MONGO_RP_ANY 0x05
#define MONGO_RP_LAST 0x05
#define MONGO_RP_DEFAULT_ACCEPTABLE_LATENCY_MS 15
typedef int (mongo_connection_sort_t)(const void *a, const void *b);
mcon_collection* mongo_find_candidate_servers(mongo_con_manager *manager, mongo_read_preference *rp, mongo_servers *servers);
mcon_collection *mongo_sort_servers(mongo_con_manager *manager, mcon_collection *col, mongo_read_preference *rp);
mcon_collection *mongo_select_nearest_servers(mongo_con_manager *manager, mcon_collection *col, mongo_server_options *options, mongo_read_preference *rp);
mongo_connection *mongo_pick_server_from_set(mongo_con_manager *manager, mcon_collection *col, mongo_read_preference *rp);
/* Info helpers */
char *mongo_connection_type(int type);
/* RP helpers */
char *mongo_read_preference_type_to_name(int type);
char *mongo_read_preference_squash_tagset(mongo_read_preference_tagset *tagset);
void mongo_read_preference_add_tag(mongo_read_preference_tagset *tagset, char *name, char *value);
void mongo_read_preference_add_tagset(mongo_read_preference *rp, mongo_read_preference_tagset *tagset);
void mongo_read_preference_tagset_dtor(mongo_read_preference_tagset *tagset);
void mongo_read_preference_dtor(mongo_read_preference *rp);
void mongo_read_preference_copy(mongo_read_preference *from, mongo_read_preference *to);
void mongo_read_preference_replace(mongo_read_preference *from, mongo_read_preference *to);
/* Debug helpers */
void mongo_print_connection_iterate_wrapper(mongo_con_manager *manager, void *elem);
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: fdm=marker
* vim: noet sw=4 ts=4
*/