示例#1
0
文件: pinba.go 项目: badoo/thunder
func NewPinbaSender(pi *PinbaInfo) *PinbaSender {
	return &PinbaSender{
		PinbaInfo: pi,
		clientPool: sync.Pool{
			New: func() interface{} {
				// ignoring error here, sucks
				// but there is a check when creating configuration for better error reporting
				c, _ := pinba.NewClient(pi.Address)
				return c
			},
		},
	}
}
示例#2
0
文件: pinba.go 项目: badoo/thunder
// process pinba configuration and return internal configuration
func PinbaInfoFromConfig(config Config) (*PinbaInfo, error) {
	daemonConfig := config.GetDaemonConfig()

	pi := &PinbaInfo{
		Address:      daemonConfig.GetPinbaAddress(),
		ServiceName:  daemonConfig.GetServiceName(),
		InstanceName: daemonConfig.GetServiceInstanceName(),
	}

	if pi.Address == "" {
		return nil, fmt.Errorf("pinba_address not set or empty")
	}

	// check that client can be created, for better error reporting
	_, err := pinba.NewClient(pi.Address)
	if err != nil {
		return nil, err
	}

	return pi, nil
}