// New returns a new Client instance. The second parameter is serializer, it can be nil.
New returns a new Client instance. The second parameter is serializer, it can be nil.
// New returns a new Client instance . The second parameter is serializer it can be nil .
func New(c *Config) (*Client, error) {
	if c == nil {
		return nil, fmt.Errorf("config cannot be nil")
	}
	if len(c.Servers) == 0 {
		return nil, fmt.Errorf("servers cannot be empty")
	}
	if c.Serializer == nil {
		c.Serializer = serializer.NewGobSerializer()
	}
	if c.MaxListenersPerStream <= 0 {
		c.MaxListenersPerStream = maxListenersPerStream
	}
	err := c.Client.Sanitize()
	if err != nil {
		return nil, err
	}
	client := transport.NewClient(c.Client)
	createStreamFunction = client.CreateStream
	return &Client{
		roundRobin:   newRoundRobin(c.Servers),
		config:       c,
		client:       client,
		serializer:   c.Serializer,
		entryFormats: c.EntryFormats,
		streams:      &streams{m: make(map[uint64]*stream)},
	}, nil
}
func New ( c * Config ) ( * Client , error ) { if c == nil { return nil , fmt . Errorf ( " " ) } if len ( c . Servers ) == 0 { return nil , fmt . Errorf ( " " ) } if c . Serializer == nil { c . Serializer = serializer . NewGobSerializer ( ) } if c . MaxListenersPerStream <= 0 { c . MaxListenersPerStream = maxListenersPerStream } err := c . Client . Sanitize ( ) if err != nil { return nil , err } client := transport . NewClient ( c . Client ) createStreamFunction = client . CreateStream return & Client { roundRobin : newRoundRobin ( c . Servers ) , config : c , client : client , serializer : c . Serializer , entryFormats : c . EntryFormats , streams : & streams { m : make ( map [ uint64 ] * stream ) } , } , nil }
New returns a new Client instance.
New returns a new Client instance .
// About the hack: This looks weird, but I need to mock client.CreateStream function to test streams // independently. I don't want to use a mocking library for this. So I created a function named // createStreamFunction and I overwrite that function in test.