func (c *X509SVIDClient) Stop() error {
	if err := c.stateManager.StopIfStoppable(); err != nil {
		return fmt.Errorf("spiffe/workload: %v", err)
	}
	c.cancelFn()
	c.wg.Wait()
	return nil
}
Stop stops the client and waits for the watch loop to end.
package workload
import (
	"context"
	"crypto"
	"crypto/x509"
	"crypto/x509/pkix"
	"fmt"
	"sync"
	"time"
	"github.com/spiffe/go-spiffe/proto/spiffe/workload"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/metadata"
	"google.golang.org/grpc/status"
)
type X509SVIDs struct {
	SVIDs []*X509SVID
	CRL *pkix.CertificateList
}
func (x *X509SVIDs) Default() *X509SVID {
	return x.SVIDs[0]
}
type X509SVID struct {
	SPIFFEID                  string
	PrivateKey                crypto.Signer
	Certificates              []*x509.Certificate
	TrustBundle               []*x509.Certificate
	TrustBundlePool           *x509.CertPool
	FederatedTrustBundles     map[string][]*x509.Certificate
	FederatedTrustBundlePools map[string]*x509.CertPool
}
type X509SVIDWatcher interface {
	UpdateX509SVIDs(*X509SVIDs)
	OnError(err error)
}
type X509SVIDClient struct {
	watcher      X509SVIDWatcher
	dialer       *Dialer
	wg           sync.WaitGroup
	ctx          context.Context
	cancelFn     func()
	backoff      *backoff
	stateManager *clientStateManager
}
func NewX509SVIDClient(watcher X509SVIDWatcher, opts ...DialOption) (*X509SVIDClient, error) {
	dialer, err := NewDialer(opts...)
	if err != nil {
		return nil, err
	}
	ctx, cancel := context.WithCancel(context.Background())
	return &X509SVIDClient{
		dialer:       dialer,
		watcher:      watcher,
		ctx:          ctx,
		cancelFn:     cancel,
		backoff:      newBackoff(),
		stateManager: newClientStateManager(),
	}, nil
}
func (c *X509SVIDClient) Start() error {
	if err := c.stateManager.StartIfStartable(); err != nil {
		return fmt.Errorf("spiffe/workload: %v", err)
	}
	c.wg.Add(1)
	go c.run()
	return nil
}