// Init - initializes policy system from policy.json of all buckets.
777142
func (sys *PolicySys) Init(objAPI ObjectLayer) error {
	if objAPI == nil {
		return errInvalidArgument
	}

	defer func() {
		// Refresh PolicySys in background.
		go func() {
			ticker := time.NewTicker(globalRefreshBucketPolicyInterval)
			defer ticker.Stop()
			for {
				select {
				case <-GlobalServiceDoneCh:
					return
				case <-ticker.C:
					sys.refresh(objAPI)
				}
			}
		}()
	}()

	doneCh := make(chan struct{})
	defer close(doneCh)

	// Initializing policy needs a retry mechanism for
	// the following reasons:
	//  - Read quorum is lost just after the initialization
	//    of the object layer.
	for range newRetryTimerSimple(doneCh) {
		// Load PolicySys once during boot.
		if err := sys.refresh(objAPI); err != nil {
			if err == errDiskNotFound ||
				strings.Contains(err.Error(), InsufficientReadQuorum{}.Error()) ||
				strings.Contains(err.Error(), InsufficientWriteQuorum{}.Error()) {
				logger.Info("Waiting for policy subsystem to be initialized..")
				continue
			}
			return err
		}
		break
	}
	return nil
}
1367647
func (p Delete) Init(ctx sessionctx.Context) *Delete {
	p.basePlan = newBasePlan(ctx, TypeDelete)
	return &p
}
657437
func (s *BaseGenerator) Init() {
	s.Position = vm.Position{State: vm.NewState()}
}
756109
func (f *FlagSet) Init(name string, errorHandling ErrorHandling) {
	f.name = name
	f.envPrefix = EnvironmentPrefix
	f.errorHandling = errorHandling
}
831767
func (c *importFilesystemCommand) Init(args []string) error {
	if len(args) < 3 {
		return errors.New("import-filesystem requires a storage provider, provider ID, and storage name")
	}
	c.storagePool = args[0]
	c.storageProviderId = args[1]
	c.storageName = args[2]

	if !storage.IsValidPoolName(c.storagePool) {
		return errors.NotValidf("pool name %q", c.storagePool)
	}

	validStorageName, err := regexp.MatchString(names.StorageNameSnippet, c.storageName)
	if err != nil {
		return errors.Trace(err)
	}
	if !validStorageName {
		return errors.Errorf("%q is not a valid storage name", c.storageName)
	}
	return nil
}
277553
func (c *infoCommand) Init(args []string) (err error) {
	c.Username, err = cmd.ZeroOrOneArgs(args)
	return err
}
821999
func (c *Config) Init(prvKey *ecdsa.PrivateKey, nodeKey *ecdsa.PrivateKey) error {

	// create swarm dir and record key
	err := c.createAndSetPath(c.Path, prvKey)
	if err != nil {
		return fmt.Errorf("Error creating root swarm data directory: %v", err)
	}
	c.setKey(prvKey)

	// create the new enode record
	// signed with the ephemeral node key
	enodeParams := &network.EnodeParams{
		PrivateKey: prvKey,
		EnodeKey:   nodeKey,
		Lightnode:  c.LightNodeEnabled,
		Bootnode:   c.BootnodeMode,
	}
	c.Enode, err = network.NewEnode(enodeParams)
	if err != nil {
		return fmt.Errorf("Error creating enode: %v", err)
	}

	// initialize components that depend on the swarm instance's private key
	if c.SwapEnabled {
		c.Swap.Init(c.Contract, prvKey)
	}

	c.LocalStoreParams.Init(c.Path)
	c.LocalStoreParams.BaseKey = common.FromHex(c.BzzKey)

	c.Pss = c.Pss.WithPrivateKey(c.privateKey)
	return nil
}
950775
func (c *Config) Init() {
	if c.Tags == nil {
		c.Tags = make(map[string]string)
	}
}
833485
func (d *FakeStateDriver) Init(instInfo *core.InstanceInfo) error {
	d.TestState = make(map[string]valueData)

	return nil
}
497551
func (m *BaseShardManager) Init(
	shardFunc func(key string, numShard int) (shard int),
	logError func(err error),
	logInfo func(v ...interface{}),
	options net2.ConnectionOptions) {

	m.InitWithPool(
		shardFunc,
		logError,
		logInfo,
		net2.NewMultiConnectionPool(options))
}
529266
func (m *Manager) Init() error {
	for _, manager := range m.managers {
		if err := manager.Init(); err != nil {
			return err
		}
	}
	return nil
}
1194924
func (c *Context) init(response http.ResponseWriter, request *http.Request) {
	c.Response = response
	c.Request = request
	c.data = nil
	c.index = -1
	c.writer = DefaultDataWriter
}
1286295
func (fs *FlagSet) Init(name string, errorHandling ErrorHandling) {
	fs.name = name
	fs.errorHandling = errorHandling
}
539291
func (p *Provider) Init() error {
	fm := template.FuncMap{
		"strsToItfs": func(values []string) []interface{} {
			var r []interface{}
			for _, v := range values {
				r = append(r, v)
			}
			return r
		},
	}

	defaultRuleTpl, err := provider.MakeDefaultRuleTemplate(p.DefaultRule, fm)
	if err != nil {
		return fmt.Errorf("error while parsing default rule: %v", err)
	}

	p.defaultRuleTpl = defaultRuleTpl
	return nil
}
48156
func (t *ObjectTree) Init(flags byte) *ObjectTree {
	t.Tree.Init(objectCompare, flags)
	return t
}
21464
func (s *GRPCServer) Init() error {
	// Create our server
	var opts []grpc.ServerOption
	if s.TLS != nil {
		opts = append(opts, grpc.Creds(credentials.NewTLS(s.TLS)))
	}
	s.server = s.Server(opts)

	// Register the health service
	healthCheck := health.NewServer()
	healthCheck.SetServingStatus(
		GRPCServiceName, grpc_health_v1.HealthCheckResponse_SERVING)
	grpc_health_v1.RegisterHealthServer(s.server, healthCheck)

	// Register the broker service
	brokerServer := newGRPCBrokerServer()
	plugin.RegisterGRPCBrokerServer(s.server, brokerServer)
	s.broker = newGRPCBroker(brokerServer, s.TLS)
	go s.broker.Run()

	// Register the controller
	controllerServer := &grpcControllerServer{
		server: s,
	}
	plugin.RegisterGRPCControllerServer(s.server, controllerServer)

	// Register all our plugins onto the gRPC server.
	for k, raw := range s.Plugins {
		p, ok := raw.(GRPCPlugin)
		if !ok {
			return fmt.Errorf("%q is not a GRPC-compatible plugin", k)
		}

		if err := p.GRPCServer(s.broker, s.server); err != nil {
			return fmt.Errorf("error registering %q: %s", k, err)
		}
	}

	return nil
}
816001
func (env *Environment) Init(args map[string]string) error {
	env.infix = "_"
	env.prefix = ""
	env.fields = make(map[string]string)

	if envPrefix, ok := args["prefix"]; ok {
		env.prefix = envPrefix
	}
	if envInfix, ok := args["infix"]; ok {
		env.infix = envInfix
	}

	if v := os.Getenv("GOFIGURE_ENV_ARRAY"); v == "1" || strings.ToLower(v) == "true" || strings.ToLower(v) == "y" {
		env.supportArrays = true
	}

	return nil
}