Beispiel #1
0
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
			},
		},
	}
}
Beispiel #2
0
// 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
}