lxd/cluster/gateway.go
func NewGateway(db *db.Node, cert *shared.CertInfo, options ...Option) (*Gateway, error) {
	ctx, cancel := context.WithCancel(context.Background())

	o := newOptions()
	for _, option := range options {
		option(o)

	}

	gateway := &Gateway{
		db:        db,
		cert:      cert,
		options:   o,
		ctx:       ctx,
		cancel:    cancel,
		upgradeCh: make(chan struct{}, 16),
		acceptCh:  make(chan net.Conn),
		store:     &dqliteServerStore{},
	}

	err := gateway.init()
	if err != nil {
		return nil, err
	}

	return gateway, nil
}
func NewGateway(db *db.Node, cert *shared.CertInfo, options ...Option) (*Gateway, error) {
	ctx, cancel := context.WithCancel(context.Background())

	o := newOptions()
	for _, option := range options {
		option(o)

	}

	gateway := &Gateway{
		db:        db,
		cert:      cert,
		options:   o,
		ctx:       ctx,
		cancel:    cancel,
		upgradeCh: make(chan struct{}, 16),
		acceptCh:  make(chan net.Conn),
		store:     &dqliteServerStore{},
	}

	err := gateway.init()
	if err != nil {
		return nil, err
	}

	return gateway, nil
}
func NewGateway ( db * db . Node , cert * shared . CertInfo , options ... Option ) ( * Gateway , error ) { ctx , cancel := context . WithCancel ( context . Background ( ) ) o := newOptions ( ) for _ , option := range options { option ( o ) } gateway := & Gateway { db : db , cert : cert , options : o , ctx : ctx , cancel : cancel , upgradeCh : make ( chan struct { } , 16 ) , acceptCh : make ( chan net . Conn ) , store : & dqliteServerStore { } , } err := gateway . init ( ) if err != nil { return nil , err } return gateway , nil }
// NewGateway creates a new Gateway for managing access to the dqlite cluster.
//
// When a new gateway is created, the node-level database is queried to check
// what kind of role this node plays and if it's exposed over the network. It
// will initialize internal data structures accordingly, for example starting a
// dqlite driver if this node is a database node.
//
// After creation, the Daemon is expected to expose whatever http handlers the
// HandlerFuncs method returns and to access the dqlite cluster using the gRPC
// dialer returned by the Dialer method.
NewGateway creates a new Gateway for managing access to the dqlite cluster . When a new gateway is created the node - level database is queried to check what kind of role this node plays and if it s exposed over the network . It will initialize internal data structures accordingly for example starting a dqlite driver if this node is a database node . After creation the Daemon is expected to expose whatever http handlers the HandlerFuncs method returns and to access the dqlite cluster using the gRPC dialer returned by the Dialer method .