-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconst.py
More file actions
59 lines (52 loc) · 1.51 KB
/
const.py
File metadata and controls
59 lines (52 loc) · 1.51 KB
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
# -*- coding: utf-8 -*-
# File @ const.py
# Create @ 2017/8/10 14:23
# Author @ 819070918@qq.com
import requests
EUREKA_DEFAULT_SAME_AS = 1
EUREKA_DEFAULT_VALUE = 2
EUREKA_INSTANCE_DEFINITION = {
'needed': [
'ipAddr', 'port', 'app'
],
'needed-with-default': [
('hostName', EUREKA_DEFAULT_SAME_AS, 'ipAddr'),
('port', EUREKA_DEFAULT_SAME_AS, 'port'),
('securePort', EUREKA_DEFAULT_VALUE, {
'$': 443,
'@enabled': 'false'
}),
('dataCenterInfo', EUREKA_DEFAULT_VALUE, {
'name': 'MyOwn',
'@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo'
}),
('leaseInfo', EUREKA_DEFAULT_VALUE, {
'durationInSecs': 60,
'evictionDurationInSecs': 60,
}),
('homePageUrl', EUREKA_DEFAULT_SAME_AS, 'ipAddr'),
('healthCheckUrl', EUREKA_DEFAULT_SAME_AS, 'ipAddr')
],
'transformations': [
('port', lambda p: is_number(p), lambda p: {'$': int(p), '@enabled': 'true'}),
('securePort', lambda p: is_number(p), lambda p: {'$': int(p), '@enabled': 'true'}),
]
}
EUREKA_HEADERS = {
'POST': {'Content-Type': 'application/json'},
'PUT': {},
'GET': {'Accept': 'application/json'},
'DELETE': {}
}
EUREKA_REQUESTS = {
'POST': requests.post,
'PUT': requests.put,
'GET': requests.get,
'DELETE': requests.delete
}
def is_number(s):
try:
int(s)
return True
except (ValueError, TypeError):
return False