func New(cfg *Config, logger logger.Logger, registerer prometheus.Registerer) (*Manager, error) {
	service := &Manager{
		cfg:        cfg,
		registerer: registerer,
		methods:    &sync.Map{},
		Logger:     logger.NewLogger("protoManager"),
	}
	if cfg.Synchronization.Enable {
		synchronization, err := synchronization.New(cfg.Synchronization, logger, registerer)
		if err != nil {
			return nil, err
		}
		service.synchronization = synchronization
		if err := service.synchronizeProto(context.Background(), true); err != nil {
			return nil, err
		}
	} else {
		if err := service.loadProto(); err != nil {
			return nil, err
		}
	}
	return service, nil
}
New is used to init service
package protomanager
import (
	"bytes"
	"context"
	"errors"
	"io/fs"
	"os"
	"path/filepath"
	"sync"
	"time"
	"github.com/jhump/protoreflect/desc"
	"github.com/jhump/protoreflect/desc/protoparse"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/spf13/pflag"
	"github.com/bilibili-base/powermock/pkg/protomanager/synchronization"
	"github.com/bilibili-base/powermock/pkg/util"
	"github.com/bilibili-base/powermock/pkg/util/logger"
)
type Provider interface {
	Start(ctx context.Context, cancelFunc context.CancelFunc) error
	GetMethod(name string) (*desc.MethodDescriptor, bool)
}
type Manager struct {
	cfg *Config
	methods         *sync.Map
	methodsLock     sync.Mutex
	synchronization *synchronization.Service
	registerer prometheus.Registerer
	logger.Logger
}
type Config struct {
	ProtoImportPaths []string
	ProtoDir         string
	Synchronization  *synchronization.Config
}
func NewConfig() *Config {
	var protoImportPaths []string
	if goPath := os.Getenv("GOPATH"); goPath != "" {
		protoImportPaths = append(protoImportPaths, goPath, filepath.Join(goPath, "bin"))
	}
	return &Config{
		ProtoImportPaths: protoImportPaths,
		ProtoDir:         "./",
		Synchronization:  synchronization.NewConfig(),
	}
}
func (c *Config) RegisterFlagsWithPrefix(prefix string, f *pflag.FlagSet) {
	f.StringArrayVar(&c.ProtoImportPaths, prefix+"protoManager.protoImportPaths", c.ProtoImportPaths, "proto import paths")
	f.StringVar(&c.ProtoDir, prefix+"protoManager.protoDir", c.ProtoDir, "proto dir to load")
	c.Synchronization.RegisterFlagsWithPrefix(prefix+"protoManager.synchronization.", f)
}
func (c *Config) Validate() error {
	if c.ProtoDir == "" {
		return errors.New("protoDir is required")
	}
	return nil
}