File: ratelimit.pp

package info (click to toggle)
puppet-module-swift 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,400 kB
  • sloc: ruby: 9,593; python: 38; sh: 10; makefile: 10
file content (82 lines) | stat: -rw-r--r-- 2,622 bytes parent folder | download
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
72
73
74
75
76
77
78
79
80
81
82
# == Class: swift::proxy::ratelimit
#
# Configure swift ratelimit.
#
# See Swift's ratelimit documentation for more detail about the values.
#
# === Parameters
#
# [*clock_accuracy*]
#   (optional) The accuracy of swift proxy servers' clocks.
#   1000 is 1ms max difference. No rate should be higher than this.
#   Defaults to $facts['os_service_default'].
#
# [*max_sleep_time_seconds*]
#   (optional) Time before the app returns a 498 response.
#   Defaults to $facts['os_service_default'].
#
# [*log_sleep_time_seconds*]
#   (optional) if >0, enables logging of sleeps longer than the value.
#   Defaults to $facts['os_service_default'].
#
# [*rate_buffer_seconds*]
#   (optional) Time in second the rate counter can skip.
#   Defaults to $facts['os_service_default'].
#
# [*account_ratelimit*]
#   (optional) if >0, limits PUT and DELETE requests to containers
#   Defaults to $facts['os_service_default'].
#
# [*container_ratelimit*]
#   (optional) Hash of size(keys) and requests per seconds(values).
#   Defaults to {}.
#
# [*container_listing_ratelimit*]
#   (optional) Hash of size(keys) and requests per seconds(values).
#   Defaults to {}.
#
# == Dependencies
#
# == Examples
#
# == Authors
#
#   Francois Charlier fcharlier@ploup.net
#
# == Copyright
#
# Copyright 2012 eNovance licensing@enovance.com
#
class swift::proxy::ratelimit(
  $clock_accuracy                   = $facts['os_service_default'],
  $max_sleep_time_seconds           = $facts['os_service_default'],
  $log_sleep_time_seconds           = $facts['os_service_default'],
  $rate_buffer_seconds              = $facts['os_service_default'],
  $account_ratelimit                = $facts['os_service_default'],
  Hash $container_ratelimit         = {},
  Hash $container_listing_ratelimit = {},
) {

  include swift::deps

  swift_proxy_config {
    'filter:ratelimit/use':                    value => 'egg:swift#ratelimit';
    'filter:ratelimit/clock_accuracy':         value => $clock_accuracy;
    'filter:ratelimit/max_sleep_time_seconds': value => $max_sleep_time_seconds;
    'filter:ratelimit/log_sleep_time_seconds': value => $log_sleep_time_seconds;
    'filter:ratelimit/rate_buffer_seconds':    value => $rate_buffer_seconds;
    'filter:ratelimit/account_ratelimit':      value => $account_ratelimit;
  }

  $container_ratelimit.each | $size, $limit | {
    swift_proxy_config {
      "filter:ratelimit/container_ratelimit_${size}": value => $limit;
    }
  }

  $container_listing_ratelimit.each | $size, $limit | {
    swift_proxy_config {
      "filter:ratelimit/container_listing_ratelimit_${size}": value => $limit;
    }
  }
}