// NewFactory returns a working factory.
NewFactory returns a working factory.
// NewFactory returns a working factory .
func NewFactory(ctx context.Context, config Config, fetchOnly bool) (vc.Factory, error) {
	span, _ := trace(ctx, "NewFactory")
	defer span.Finish()
	err := config.VMConfig.Valid()
	if err != nil {
		return nil, err
	}
	if fetchOnly && config.Cache > 0 {
		return nil, fmt.Errorf("cache factory does not support fetch")
	}
	var b base.FactoryBase
	if config.VMCache && config.Cache == 0 {
		b, err = grpccache.New(ctx, config.VMCacheEndpoint)
		if err != nil {
			return nil, err
		}
	} else {
		if config.Template {
			if fetchOnly {
				b, err = template.Fetch(config.VMConfig, config.TemplatePath)
				if err != nil {
					return nil, err
				}
			} else {
				b, err = template.New(ctx, config.VMConfig, config.TemplatePath)
				if err != nil {
					return nil, err
				}
			}
		} else {
			b = direct.New(ctx, config.VMConfig)
		}
		if config.Cache > 0 {
			b = cache.New(ctx, config.Cache, b)
		}
	}
	return &factory{b}, nil
}
func NewFactory ( ctx context . Context , config Config , fetchOnly bool ) ( vc . Factory , error ) { span , _ := trace ( ctx , " " ) defer span . Finish ( ) err := config . VMConfig . Valid ( ) if err != nil { return nil , err } if fetchOnly && config . Cache > 0 { return nil , fmt . Errorf ( " " ) } var b base . FactoryBase if config . VMCache && config . Cache == 0 { b , err = grpccache . New ( ctx , config . VMCacheEndpoint ) if err != nil { return nil , err } } else { if config . Template { if fetchOnly { b , err = template . Fetch ( config . VMConfig , config . TemplatePath ) if err != nil { return nil , err } } else { b , err = template . New ( ctx , config . VMConfig , config . TemplatePath ) if err != nil { return nil , err } } } else { b = direct . New ( ctx , config . VMConfig ) } if config . Cache > 0 { b = cache . New ( ctx , config . Cache , b ) } } return & factory { b } , nil }
NewFactory returns a working factory.
NewFactory returns a working factory .
// For VMCache client