func (s *Session) SetTrace(trace Tracer) {
	s.mu.Lock()
	s.trace = trace
	s.mu.Unlock()
}
SetTrace sets the default tracer for this session. This setting can also
be changed on a per-query basis.
package gocql
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"golang.org/x/net/context"
	"io"
	"net"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"time"
	"unicode"
	"github.com/gocql/gocql/internal/lru"
)
type Session struct {
	cons                Consistency
	pageSize            int
	prefetch            float64
	routingKeyInfoCache routingKeyInfoLRU
	schemaDescriber     *schemaDescriber
	trace               Tracer
	hostSource          *ringDescriber
	stmtsLRU            *preparedLRU
	connCfg *ConnConfig
	executor *queryExecutor
	pool     *policyConnPool
	policy   HostSelectionPolicy
	ring     ring
	metadata clusterMetadata
	mu sync.RWMutex
	control *controlConn
	nodeEvents   *eventDeouncer
	schemaEvents *eventDeouncer
	hosts           []HostInfo
	useSystemSchema bool
	cfg ClusterConfig
	closeMu  sync.RWMutex
	isClosed bool
}
func addrsToHosts(addrs []string, defaultPort int) ([]*HostInfo, error) {
	hosts := make([]*HostInfo, len(addrs))
	for i, hostport := range addrs {
		addr, portStr, err := net.SplitHostPort(JoinHostPort(hostport, defaultPort))
		if err != nil {
			return nil, fmt.Errorf("NewSession: unable to parse hostport of addr %q: %v", hostport, err)
		}
		port, err := strconv.Atoi(portStr)
		if err != nil {
			return nil, fmt.Errorf("NewSession: invalid port for hostport of addr %q: %v", hostport, err)
		}
		hosts[i] = &HostInfo{peer: addr, port: port, state: NodeUp}
	}
	return hosts, nil
}
func NewSession(cfg ClusterConfig) (*Session, error) {
	if len(cfg.Hosts) < 1 {
		return nil, ErrNoHosts
	}
	s := &Session{
		cons:     cfg.Consistency,
		prefetch: 0.25,
		cfg:      cfg,
		pageSize: cfg.PageSize,
		stmtsLRU: &preparedLRU{lru: lru.New(cfg.MaxPreparedStmts)},
	}
	connCfg, err := connConfig(s)
	if err != nil {
		s.Close()
		return nil, fmt.Errorf("gocql: unable to create session: %v", err)
	}
	s.connCfg = connCfg
	s.nodeEvents = newEventDeouncer("NodeEvents", s.handleNodeEvent)
	s.schemaEvents = newEventDeouncer("SchemaEvents", s.handleSchemaEvent)
	s.routingKeyInfoCache.lru = lru.New(cfg.MaxRoutingKeyInfo)
	s.hostSource = &ringDescriber{
		session:   s,
		closeChan: make(chan bool),
	}
	pool := cfg.PoolConfig.buildPool(s)
	if cfg.PoolConfig.HostSelectionPolicy == nil {
		cfg.PoolConfig.HostSelectionPolicy = RoundRobinHostPolicy()
	}
	s.pool = pool
	s.policy = cfg.PoolConfig.HostSelectionPolicy
	s.executor = &queryExecutor{
		pool:   pool,
		policy: cfg.PoolConfig.HostSelectionPolicy,
	}
	var hosts []*HostInfo
	if !cfg.disableControlConn {
		s.control = createControlConn(s)
		if err := s.control.connect(cfg.Hosts); err != nil {
			s.Close()
			return nil, fmt.Errorf("gocql: unable to create session: %v", err)
		}
		localHasRPCAddr, _ := checkSystemLocal(s.control)
		s.hostSource.localHasRpcAddr = localHasRPCAddr
		var err error
		if cfg.DisableInitialHostLookup {
			hosts, err = addrsToHosts(cfg.Hosts, cfg.Port)
		} else {
			hosts, _, err = s.hostSource.GetHosts()
		}
		if err != nil {
			s.Close()
			return nil, fmt.Errorf("gocql: unable to create session: %v", err)
		}
	} else {
		hosts, err = addrsToHosts(cfg.Hosts, cfg.Port)
	}
	for _, host := range hosts {
		if s.cfg.HostFilter == nil || s.cfg.HostFilter.Accept(host) {
			if existingHost, ok := s.ring.addHostIfMissing(host); ok {
				existingHost.update(host)
			}
			s.handleNodeUp(net.ParseIP(host.Peer()), host.Port(), false)
		}
	}
	if s.pool.Size() == 0 {
		s.Close()
		return nil, ErrNoConnectionsStarted
	}
	s.useSystemSchema = hosts[0].Version().Major >= 3
	return s, nil
}
func (s *Session) SetConsistency(cons Consistency) {
	s.mu.Lock()
	s.cons = cons
	s.mu.Unlock()
}
func (s *Session) SetPageSize(n int) {
	s.mu.Lock()
	s.pageSize = n
	s.mu.Unlock()
}
func (s *Session) SetPrefetch(p float64) {
	s.mu.Lock()
	s.prefetch = p
	s.mu.Unlock()
}