Example #1
0
func NewAppLogDrain(appGUID string) (*AppLogDrain, error) {
	d := new(AppLogDrain)

	srv, err := lineserver.NewLineServer(
		LINESERVER_PROTO,
		fmt.Sprintf("%v:0", server.LocalIPMust()))
	if err != nil {
		return nil, err
	}

	addr, err := srv.GetUDPAddr()
	if err != nil {
		return nil, err
	}

	d.appGUID = appGUID
	d.srv = srv
	d.port = addr.Port
	d.lifetime, err = time.ParseDuration(config.GetConfig().DrainLifetime)
	if err != nil {
		return nil, fmt.Errorf(
			"Invalid duration value (%v) for drain_lifetime", err)
	}
	// TODO: name should have an uniq id, to allow multiple taile
	// sessions for same app.
	d.drainName = fmt.Sprintf("%s.%s", DRAIN_PREFIX, d.appGUID)

	return d, nil
}
Example #2
0
func getApplogEndpointUri() string {
	uri := config.GetConfig().Hostname
	if uri == "" {
		clusterConfig := config.GetClusterConfig()
		uri = strings.Replace(clusterConfig.Endpoint, "api.", "logs.", 1)
	}
	return uri
}
Example #3
0
func TestGetApplogEndpointUriDefault(t *testing.T) {
	config.GetClusterConfig().Endpoint = "api.stackato.example"
	config.GetConfig().Hostname = ""
	uri := getApplogEndpointUri()
	expected := "logs.stackato.example"
	if uri != expected {
		t.Errorf("Got unexpected applog endpoint uri %v, expected %v",
			uri, expected)
	}
}
Example #4
0
func TestGetApplogEndpointUriCustom(t *testing.T) {
	config.GetClusterConfig().Endpoint = "api.stackato.example"
	expected := "example.test"
	config.GetConfig().Hostname = expected
	uri := getApplogEndpointUri()
	if uri != expected {
		t.Errorf("Got unexpected applog endpoint uri %v, expected %v",
			uri, expected)
	}
}