コード例 #1
0
ファイル: transport.go プロジェクト: koding/koding
// NewClient gives custom HTTP client for Softlayer API.
func NewClient() *http.Client {
	return httputil.NewClient(transportParams)
}
コード例 #2
0
	"time"

	"koding/httputil"
	"koding/klientctl/config"
	"koding/klientctl/klient"
	"koding/klientctl/klientctlerrors"

	"github.com/codegangsta/cli"
	kodinglogging "github.com/koding/logging"
)

var kiteHTTPResponse = []byte("Welcome to SockJS!")

var defaultClient = httputil.NewClient(&httputil.ClientConfig{
	DialTimeout:           3 * time.Second,
	RoundTripTimeout:      3 * time.Second,
	TLSHandshakeTimeout:   3 * time.Second,
	ResponseHeaderTimeout: 3 * time.Second,
})

// TODO(leeola): deprecate this default, instead passing it as a dependency
// to the users of it.
var defaultHealthChecker *HealthChecker

// HealthChecker implements state for the various HealthCheck functions,
// ideal for mocking the health check interfaces (local kite, remote http,
// remote kite, etc)
type HealthChecker struct {
	Log        kodinglogging.Logger
	HTTPClient *http.Client

	// Used for verifying a locally / remotely running kite
コード例 #3
0
ファイル: publicip.go プロジェクト: koding/koding
	return DefaultClient.PublicIP()
}

// IsReachable returns nil error when the given addr
// is reachable from the internet.
func IsReachable(addr string) error {
	return DefaultClient.IsReachable(addr)
}

var fallback director

// DefaultClient defines default behavior for IP fetching and testing.
var DefaultClient = &Client{
	Client: httputil.NewClient(&httputil.ClientConfig{
		DialTimeout:           10 * time.Second,
		RoundTripTimeout:      10 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ResponseHeaderTimeout: 10 * time.Second,
	}),
	MaxRetries:          3,
	Backoff:             fallback.Backoff,
	ShouldRetry:         fallback.ShouldRetry,
	EndpointPublicIP:    fallback.EndpointPublicIP,
	EndpointIsReachable: fallback.EndpointIsReachable,
}

type director struct {
	fallback bool
}

func (d *director) Backoff(int) time.Duration {
	return 100 * time.Millisecond
コード例 #4
0
ファイル: discover.go プロジェクト: koding/koding
	"io/ioutil"
	"net"
	"net/http"
	"net/url"
	"path"
	"time"

	"github.com/koding/logging"

	"koding/httputil"
)

var defaultHTTPClient = httputil.NewClient(&httputil.ClientConfig{
	DialTimeout:           10 * time.Second,
	RoundTripTimeout:      60 * time.Second,
	TLSHandshakeTimeout:   10 * time.Second,
	ResponseHeaderTimeout: 60 * time.Second,
	KeepAlive:             30 * time.Second,
})

var defaultLog = logging.NewCustom("discover", false)

type Endpoint struct {
	Addr     string `json:"addr"`
	Protocol string `json:"protocol"`
	Local    bool   `json:"local"`
}

type Endpoints []*Endpoint

func (e Endpoints) Filter(fn FilterFunc) (res Endpoints) {