-
Notifications
You must be signed in to change notification settings - Fork 90
/
config_provider.go
59 lines (50 loc) · 2.27 KB
/
config_provider.go
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
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package main
import (
"encoding/json"
"github.com/facebookincubator/dhcplb/lib"
)
// DefaultConfigProvider holds configuration for the server.
type DefaultConfigProvider struct{}
// NewDefaultConfigProvider returns a new DefaultConfigProvider
func NewDefaultConfigProvider() *DefaultConfigProvider {
return &DefaultConfigProvider{}
}
// NewHostSourcer returns a dhcplb.DHCPServerSourcer interface.
// The default config loader is able to instantiate a FileSourcer by itself, so
// NewHostSourcer here will simply return (nil, nil).
// The FileSourcer implemments dhcplb.DHCPServerSourcer interface.
// If you are writing your own implementation of dhcplb you could write your
// custom sourcer implementation here.
// sourcerType
// The NewHostSourcer function is passed values from the host_sourcer json
// config option with the sourcerType being the part of the string before
// the : and args the remaining portion.
// ex: file:hosts-v4.txt,hosts-v4-rc.txt in the json config file will have
// sourcerType="file" and args="hosts-v4.txt,hosts-v4-rc.txt".
func (h DefaultConfigProvider) NewHostSourcer(sourcerType, args string, version int) (dhcplb.DHCPServerSourcer, error) {
return nil, nil
}
// ParseExtras is used to return extra config. Here we return nil because we
// don't need any extra configuration in the opensource version of dhcplb.
func (h DefaultConfigProvider) ParseExtras(data json.RawMessage) (interface{}, error) {
return nil, nil
}
// NewDHCPBalancingAlgorithm returns a DHCPBalancingAlgorithm implementation.
// This can be used if you need to create your own balancing algorithm and
// integrate it with your infra without necesarily having to realase your code
// to github.
func (h DefaultConfigProvider) NewDHCPBalancingAlgorithm(version int) (dhcplb.DHCPBalancingAlgorithm, error) {
return nil, nil
}
// NewHandler takes an interface with extra configurations and returns a
// Handler used for serving DHCP requests. It is only needed when using dhcplb
// in server mode.
func (h DefaultConfigProvider) NewHandler(extras interface{}, version int) (dhcplb.Handler, error) {
return nil, nil
}