Ejemplo n.º 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
}
Ejemplo n.º 2
0
func (c *Client) doozer() skynet.DoozerConnection {
	if c.DoozerConn == nil {
		c.DoozerConn = skynet.NewDoozerConnectionFromConfig(*c.Config.DoozerConfig, c.Config.Log)

		c.DoozerConn.Connect()
	}

	return c.DoozerConn
}
Ejemplo n.º 3
0
// only call this from doozerMux
func (s *Service) doozer() skynet.DoozerConnection {
	if s.DoozerConn == nil {
		s.DoozerConn = skynet.NewDoozerConnectionFromConfig(*s.Config.DoozerConfig, s.Log)

		s.DoozerConn.Connect()
	}

	return s.DoozerConn
}
Ejemplo n.º 4
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
}
Ejemplo n.º 5
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
}
Ejemplo n.º 6
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
}