// CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service
429183
func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine {
	// If proof-of-authority is requested, set it up
	if chainConfig.Clique != nil {
		return clique.New(chainConfig.Clique, db)
	}
	// Otherwise assume proof-of-work
	switch config.PowMode {
	case ethash.ModeFake:
		log.Warn("Ethash used in fake mode")
		return ethash.NewFaker()
	case ethash.ModeTest:
		log.Warn("Ethash used in test mode")
		return ethash.NewTester(nil, noverify)
	case ethash.ModeShared:
		log.Warn("Ethash used in shared mode")
		return ethash.NewShared()
	default:
		engine := ethash.New(ethash.Config{
			CacheDir:       ctx.ResolvePath(config.CacheDir),
			CachesInMem:    config.CachesInMem,
			CachesOnDisk:   config.CachesOnDisk,
			DatasetDir:     config.DatasetDir,
			DatasetsInMem:  config.DatasetsInMem,
			DatasetsOnDisk: config.DatasetsOnDisk,
		}, notify, noverify)
		engine.SetThreads(-1) // Disable CPU mining
		return engine
	}
}
260350
func NewEngine(path string, c Config, options ...Option) *Engine {
	e := &Engine{
		config:              c,
		path:                path,
		defaultMetricLabels: prometheus.Labels{},
		logger:              zap.NewNop(),
	}

	// Initialize series file.
	e.sfile = tsdb.NewSeriesFile(c.GetSeriesFilePath(path))
	e.sfile.LargeWriteThreshold = c.TSDB.LargeSeriesWriteThreshold

	// Initialise index.
	e.index = tsi1.NewIndex(e.sfile, c.Index,
		tsi1.WithPath(c.GetIndexPath(path)))

	// Initialize WAL
	e.wal = wal.NewWAL(c.GetWALPath(path))
	e.wal.WithFsyncDelay(time.Duration(c.WAL.FsyncDelay))
	e.wal.SetEnabled(c.WAL.Enabled)

	// Initialise Engine
	e.engine = tsm1.NewEngine(c.GetEnginePath(path), e.index, c.Engine,
		tsm1.WithSnapshotter(e))

	// Apply options.
	for _, option := range options {
		option(e)
	}

	// Set default metrics labels.
	e.engine.SetDefaultMetricLabels(e.defaultMetricLabels)
	e.sfile.SetDefaultMetricLabels(e.defaultMetricLabels)
	e.index.SetDefaultMetricLabels(e.defaultMetricLabels)
	e.wal.SetDefaultMetricLabels(e.defaultMetricLabels)
	e.retentionEnforcer.SetDefaultMetricLabels(e.defaultMetricLabels)

	return e
}
68432
func CreateProvidersFromConstraints(ns string, sccs []*securityapi.SecurityContextConstraints, client kubernetes.Interface) ([]SecurityContextConstraintsProvider, []error) {
	var (
		// namespace is declared here for reuse but we will not fetch it unless required by the matched constraints
		namespace *corev1.Namespace
		// collected providers
		providers []SecurityContextConstraintsProvider
		// collected errors to return
		errs []error
	)

	// set pre-allocated values on constraints
	for _, constraint := range sccs {
		var (
			provider SecurityContextConstraintsProvider
			err      error
		)
		provider, namespace, err = CreateProviderFromConstraint(ns, namespace, constraint, client)
		if err != nil {
			errs = append(errs, err)
			continue
		}
		providers = append(providers, provider)
	}
	return providers, errs
}
605979
func NewEngine(cfg Config) EngineInternal {
	eng := &engineImpl{cfg: cfg}
	eng.init()
	return eng
}
1113728
func NewEngine(joiner string, defaultTemplate *Template, templates []string) (*Engine, error) {
	engine := Engine{
		joiner:  joiner,
		matcher: newMatcher(defaultTemplate),
	}
	templateSpecs := parseTemplateSpecs(templates)

	for _, templateSpec := range templateSpecs {
		if err := engine.matcher.addSpec(templateSpec); err != nil {
			return nil, err
		}
	}

	return &engine, nil
}
1365710
func NewEngine(tsv TabletService, se *schema.Engine, config tabletenv.TabletConfig) *Engine {
	return &Engine{
		tsv: tsv,
		se:  se,
		conns: connpool.New(
			config.PoolNamePrefix+"MessagerPool",
			config.MessagePoolSize,
			time.Duration(config.IdleTimeout*1e9),
			tsv,
		),
		postponeSema: sync2.NewSemaphore(config.MessagePostponeCap, 0),
		managers:     make(map[string]*messageManager),
	}
}
587535
func (c *roleBindingRestrictions) Create(roleBindingRestriction *authorization.RoleBindingRestriction) (result *authorization.RoleBindingRestriction, err error) {
	result = &authorization.RoleBindingRestriction{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("rolebindingrestrictions").
		Body(roleBindingRestriction).
		Do().
		Into(result)
	return
}
6769
func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (string, error) {
	metadata := map[string]string{
		"ssh_authorized_keys": publicKey,
	}
	if d.cfg.Metadata != nil {
		for key, value := range d.cfg.Metadata {
			metadata[key] = value
		}
	}
	if d.cfg.UserData != "" {
		metadata["user_data"] = d.cfg.UserData
	}

	instanceDetails := core.LaunchInstanceDetails{
		AvailabilityDomain: &d.cfg.AvailabilityDomain,
		CompartmentId:      &d.cfg.CompartmentID,
		ImageId:            &d.cfg.BaseImageID,
		Shape:              &d.cfg.Shape,
		SubnetId:           &d.cfg.SubnetID,
		Metadata:           metadata,
	}

	// When empty, the default display name is used.
	if d.cfg.InstanceName != "" {
		instanceDetails.DisplayName = &d.cfg.InstanceName
	}

	instance, err := d.computeClient.LaunchInstance(context.TODO(), core.LaunchInstanceRequest{LaunchInstanceDetails: instanceDetails})

	if err != nil {
		return "", err
	}

	return *instance.Id, nil
}
243789
func (loader *TemplateLoader) CreateTemplateEngine(templateEngineName string) (TemplateEngine, error) {
	if "" == templateEngineName {
		templateEngineName = GO_TEMPLATE
	}
	factory := templateLoaderMap[templateEngineName]
	if nil == factory {
		fmt.Printf("registered factories %#v\n %s \n", templateLoaderMap, templateEngineName)
		return nil, errors.New("Unknown template engine name - " + templateEngineName + ".")
	}
	templateEngine, err := factory(loader)
	if nil != err {
		return nil, errors.New("Failed to init template engine (" + templateEngineName + "), " + err.Error())
	}

	templateLog.Debug("CreateTemplateEngine: init templates", "name", templateEngineName)
	return templateEngine, nil
}
692347
func (cli *DockerCli) NewContainerizedEngineClient(sockPath string) (clitypes.ContainerizedClient, error) {
	return cli.newContainerizeClient(sockPath)
}
790765
func initSessionEngine() {
	// Check for session engine to use and assign it
	sename := Config.StringDefault("session.engine", "revel-cookie")
	if se, found := sessionEngineMap[sename]; found {
		CurrentSessionEngine = se()
	} else {
		sessionLog.Warn("Session engine '%s' not found, using default session engine revel-cookie", sename)
		CurrentSessionEngine = sessionEngineMap["revel-cookie"]()
	}
}
691655
func (env *sessionEnviron) Create(ctx callcontext.ProviderCallContext, args environs.CreateParams) error {
	return env.ensureVMFolder(args.ControllerUUID, ctx)
}
1040074
func (_m *Dispatcher) DispatchConsensus(ctx context.Context, request *orderer.ConsensusRequest) error {
	ret := _m.Called(ctx, request)

	var r0 error
	if rf, ok := ret.Get(0).(func(context.Context, *orderer.ConsensusRequest) error); ok {
		r0 = rf(ctx, request)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
514584
func NewEngine(cfg *config.EngineConfig) *Engine {
	if cfg == nil {
		defaultCfg := config.DefaultEngineConfig()
		cfg = &defaultCfg
	}
	// TODO(jsing): Validate node, peer and cluster IP configuration.
	engine := &Engine{
		config:   cfg,
		fwmAlloc: newMarkAllocator(fwmAllocBase, fwmAllocSize),
		ncc:      ncclient.NewNCC(cfg.NCCSocket),

		overrides:    make(map[string]seesaw.Override),
		overrideChan: make(chan seesaw.Override),

		vlans:    make(map[uint16]*seesaw.VLAN),
		vservers: make(map[string]*vserver),

		shutdown:    make(chan bool),
		shutdownARP: make(chan bool),
		shutdownIPC: make(chan bool),
		shutdownRPC: make(chan bool),

		vserverSnapshots: make(map[string]*seesaw.Vserver),
		vserverChan:      make(chan *seesaw.Vserver, 1000),
	}
	engine.bgpManager = newBGPManager(engine, cfg.BGPUpdateInterval)
	engine.haManager = newHAManager(engine, cfg.HAStateTimeout)
	engine.hcManager = newHealthcheckManager(engine)
	engine.syncClient = newSyncClient(engine)
	engine.syncServer = newSyncServer(engine)
	return engine
}
1224777
func (gce *Cloud) CreateTargetHTTPSProxy(urlMap *compute.UrlMap, sslCert *compute.SslCertificate, name string) (*compute.TargetHttpsProxy, error) {
	proxy := &compute.TargetHttpsProxy{
		Name:            name,
		UrlMap:          urlMap.SelfLink,
		SslCertificates: []string{sslCert.SelfLink},
	}
	op, err := gce.service.TargetHttpsProxies.Insert(gce.projectID, proxy).Do()
	if err != nil {
		return nil, err
	}
	if err = gce.waitForGlobalOp(op); err != nil {
		return nil, err
	}
	return gce.GetTargetHTTPSProxy(name)
}
184204
func (m *MockLambdaAPI) CreateAliasWithContext(arg0 aws.Context, arg1 *lambda.CreateAliasInput, arg2 ...request.Option) (*lambda.AliasConfiguration, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "CreateAliasWithContext", varargs...)
	ret0, _ := ret[0].(*lambda.AliasConfiguration)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
210195
func (d *Dispatcher) OnConsensus(channel string, sender uint64, request *orderer.ConsensusRequest) error {
	receiver := d.ChainSelector.ReceiverByChain(channel)
	if receiver == nil {
		d.Logger.Warningf("An attempt to send a consensus request to a non existing channel (%s) was made by %d", channel, sender)
		return errors.Errorf("channel %s doesn't exist", channel)
	}
	return receiver.Consensus(request, sender)
}