1/*
2Copyright 2014 The go-marathon Authors All rights reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package marathon
18
19import (
20	"io"
21	"io/ioutil"
22	"net/http"
23	"time"
24)
25
26const defaultPollingWaitTime = 500 * time.Millisecond
27
28const defaultDCOSPath = "marathon"
29
30// EventsTransport describes which transport should be used to deliver Marathon events
31type EventsTransport int
32
33// Config holds the settings and options for the client
34type Config struct {
35	// URL is the url for marathon
36	URL string
37	// EventsTransport is the events transport: EventsTransportCallback or EventsTransportSSE
38	EventsTransport EventsTransport
39	// EventsPort is the event handler port
40	EventsPort int
41	// the interface we should be listening on for events
42	EventsInterface string
43	// HTTPBasicAuthUser is the http basic auth
44	HTTPBasicAuthUser string
45	// HTTPBasicPassword is the http basic password
46	HTTPBasicPassword string
47	// CallbackURL custom callback url
48	CallbackURL string
49	// DCOSToken for DCOS environment, This will override the Authorization header
50	DCOSToken string
51	// LogOutput the output for debug log messages
52	LogOutput io.Writer
53	// HTTPClient is the HTTP client
54	HTTPClient *http.Client
55	// HTTPSSEClient is the HTTP client used for SSE subscriptions, can't have client.Timeout set
56	HTTPSSEClient *http.Client
57	// wait time (in milliseconds) between repetitive requests to the API during polling
58	PollingWaitTime time.Duration
59}
60
61// NewDefaultConfig create a default client config
62func NewDefaultConfig() Config {
63	return Config{
64		URL:             "http://127.0.0.1:8080",
65		EventsTransport: EventsTransportCallback,
66		EventsPort:      10001,
67		EventsInterface: "eth0",
68		LogOutput:       ioutil.Discard,
69		PollingWaitTime: defaultPollingWaitTime,
70	}
71}
72