Пример #1
0
 def __init__(
     self,
     instance,
     service_url,
     modes=[],
     id='geovelo',
     timeout=10,
     api_key=None,
     feed_publisher=DEFAULT_GEOVELO_FEED_PUBLISHER,
     verify=True,
     **kwargs
 ):
     self.instance = instance
     self.sn_system_id = id
     if not is_url(service_url):
         raise ValueError('service_url {} is not a valid url'.format(service_url))
     self.service_url = service_url
     self.api_key = api_key
     self.timeout = timeout
     self.modes = modes
     self.breaker = pybreaker.CircuitBreaker(
         fail_max=app.config['CIRCUIT_BREAKER_MAX_GEOVELO_FAIL'],
         reset_timeout=app.config['CIRCUIT_BREAKER_GEOVELO_TIMEOUT_S'],
     )
     self._feed_publisher = FeedPublisher(**feed_publisher) if feed_publisher else None
     self.verify = verify
Пример #2
0
 def __init__(self,
              instance,
              service_url,
              modes=[],
              id='valhalla',
              timeout=10,
              api_key=None,
              **kwargs):
     self.instance = instance
     self.sn_system_id = id
     if not is_url(service_url):
         raise ValueError(
             'service_url {} is not a valid url'.format(service_url))
     self.service_url = service_url
     self.api_key = api_key
     self.timeout = timeout
     self.modes = modes
     self.costing_options = kwargs.get('costing_options', None)
     # kilometres is default units
     self.directions_options = {'units': 'kilometers'}
     self.breaker = pybreaker.CircuitBreaker(
         fail_max=app.config['CIRCUIT_BREAKER_MAX_VALHALLA_FAIL'],
         reset_timeout=app.config['CIRCUIT_BREAKER_VALHALLA_TIMEOUT_S'],
     )
     # the mode's park cost represent the initial cost to leave the given mode
     # it is used to represent that it takes time to park a car or a bike
     # since valhalla does not handle such a time, we rig valhalla's result to add it
     self.mode_park_cost = kwargs.get(
         'mode_park_cost', {})  # a dict giving the park time (in s) by mode
Пример #3
0
 def __init__(self, instance, url, timeout=10, api_key=None, **kwargs):
     self.instance = instance
     if not is_url(url):
         raise ValueError('service_url is invalid, you give {}'.format(url))
     self.service_url = url
     self.api_key = api_key
     self.timeout = timeout
     self.costing_options = kwargs.get('costing_options', None)
     # kilometres is default units
     self.directions_options = {'units': 'kilometers'}
     self.breaker = pybreaker.CircuitBreaker(
         fail_max=app.config['CIRCUIT_BREAKER_MAX_VALHALLA_FAIL'],
         reset_timeout=app.config['CIRCUIT_BREAKER_VALHALLA_TIMEOUT_S'])
Пример #4
0
 def __init__(self,
              instance,
              service_url,
              id='geovelo',
              timeout=10,
              api_key=None,
              **kwargs):
     self.instance = instance
     self.sn_system_id = id
     if not is_url(service_url):
         raise ValueError(
             'service_url {} is not a valid url'.format(service_url))
     self.service_url = service_url
     self.api_key = api_key
     self.timeout = timeout
     self.breaker = pybreaker.CircuitBreaker(
         fail_max=app.config['CIRCUIT_BREAKER_MAX_GEOVELO_FAIL'],
         reset_timeout=app.config['CIRCUIT_BREAKER_GEOVELO_TIMEOUT_S'])