Пример #1
0
func NewClient(config *skynet.ClientConfig) *Client {
	// Sanity checks (nil pointers are baaad)
	if config.Log == nil {
		config.Log = skynet.NewConsoleSemanticLogger("skynet", os.Stderr)
	}
	if config.DoozerConfig == nil {
		config.DoozerConfig = &skynet.DoozerConfig{Uri: "localhost:8046"}
	}

	if config.MaxConnectionsToInstance == 0 {
		config.Log.Fatal("Must allow at least one instance connection")
	}

	doozerConn := skynet.NewDoozerConnectionFromConfig(*config.DoozerConfig,
		config.Log)
	client := &Client{
		Config:       config,
		DoozerConn:   doozerConn,
		Log:          config.Log,
		servicePools: map[string]*servicePool{},
	}

	client.Log.Trace(fmt.Sprintf("Created client '%+v'", client))

	client.DoozerConn.Connect()

	client.instanceMonitor = NewInstanceMonitor(client.DoozerConn, false)

	return client
}
Пример #2
0
func NewClient(config *skynet.ClientConfig) *Client {
	if config.Log == nil {
		config.Log = skynet.NewConsoleLogger(os.Stderr)
	}

	if config.ConnectionPoolSize == 0 {
		config.ConnectionPoolSize = 1
	}

	client := &Client{
		Config:     config,
		DoozerConn: skynet.NewDoozerConnectionFromConfig(*config.DoozerConfig, config.Log),
		Log:        config.Log,
	}

	client.Log.Item(config)

	client.DoozerConn.Connect()

	return client
}
Пример #3
0
func NewClient(config *skynet.ClientConfig) *Client {
	if config.Log == nil {
		config.Log = skynet.NewConsoleLogger(os.Stderr)
	}

	if config.ConnectionPoolSize == 0 {
		config.ConnectionPoolSize = 1
	}

	client := &Client{
		Config:       config,
		DoozerConn:   skynet.NewDoozerConnectionFromConfig(*config.DoozerConfig, config.Log),
		Log:          config.Log,
		servicePools: map[string]*servicePool{},
	}

	client.Log.Item(config)

	client.DoozerConn.Connect()

	client.instanceMonitor = NewInstanceMonitor(client.DoozerConn)

	return client
}
Пример #4
0
func NewClient(config *skynet.ClientConfig) *Client {
	if config.Log == nil {
		config.Log = skynet.NewConsoleLogger("skynet", os.Stderr)
	}

	if config.MaxConnectionsToInstance == 0 {
		panic("must have at least one connection allowed to an instance")
	}

	client := &Client{
		Config:       config,
		DoozerConn:   skynet.NewDoozerConnectionFromConfig(*config.DoozerConfig, config.Log),
		Log:          config.Log,
		servicePools: map[string]*servicePool{},
	}

	client.Log.Item(config)

	client.DoozerConn.Connect()

	client.instanceMonitor = NewInstanceMonitor(client.DoozerConn)

	return client
}