func NewEventsClient(provider fab.ProviderContext, identity fab.IdentityContext, peerAddress string, certificate *sm2.Certificate,
	serverhostoverride string, regTimeout time.Duration, adapter consumer.EventAdapter,
	kap keepalive.ClientParameters, failFast bool) (fab.EventsClient, error) {
	var err error
	if regTimeout < 100*time.Millisecond {
		regTimeout = 100 * time.Millisecond
		err = errors.New("regTimeout >= 0, setting to 100 msec")
	} else if regTimeout > 60*time.Second {
		regTimeout = 60 * time.Second
		err = errors.New("regTimeout > 60, setting to 60 sec")
	}
	return &eventsClient{
		RWMutex:               sync.RWMutex{},
		peerAddress:           peerAddress,
		regTimeout:            regTimeout,
		adapter:               adapter,
		TLSCertificate:        certificate,
		TLSServerHostOverride: serverhostoverride,
		provider:              provider,
		identity:              identity,
		tlsCertHash:           ccomm.TLSCertHash(provider.Config()),
		kap:                   kap,
		failFast:              failFast,
	}, err
}
NewEventsClient Returns a new grpc.ClientConn to the configured local PEER.
package consumer
import (
	"io"
	"sync"
	"time"
	"fmt"
	"golang.org/x/net/context"
	"github.com/golang/protobuf/proto"
	"google.golang.org/grpc"
	"google.golang.org/grpc/keepalive"
	"github.com/golang/protobuf/ptypes"
	apiconfig "github.com/hyperledger/fabric-sdk-go/api/apiconfig"
	fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
	"github.com/hyperledger/fabric-sdk-go/pkg/config/comm"
	ccomm "github.com/hyperledger/fabric-sdk-go/pkg/config/comm"
	"github.com/hyperledger/fabric-sdk-go/pkg/config/urlutil"
	"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
	ehpb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
	consumer "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/events/consumer"
	"github.com/hyperledger/fabric-sdk-go/pkg/logging"
	"github.com/pkg/errors"
	"github.com/hyperledger/fabric-sdk-go/internal/github.com/tjfoc/gmsm/sm2"
	credentials "github.com/hyperledger/fabric-sdk-go/internal/github.com/tjfoc/gmtls/gmcredentials"
)
var logger = logging.NewLogger("fabric_sdk_go")
const defaultTimeout = time.Second * 3
type eventsClient struct {
	sync.RWMutex
	peerAddress            string
	regTimeout             time.Duration
	stream                 ehpb.Events_ChatClient
	adapter                consumer.EventAdapter
	TLSCertificate         *sm2.Certificate
	TLSServerHostOverride  string
	tlsCertHash            []byte
	clientConn             *grpc.ClientConn
	provider               fab.ProviderContext
	identity               fab.IdentityContext
	processEventsCompleted chan struct{}
	kap                    keepalive.ClientParameters
	failFast               bool
}