// initialize is used to set up all of the buckets.
480355
func (b *BoltStore) initialize() error {
	tx, err := b.conn.Begin(true)
	if err != nil {
		return err
	}
	defer tx.Rollback()

	// Create all the buckets
	if _, err := tx.CreateBucketIfNotExists(dbLogs); err != nil {
		return err
	}
	if _, err := tx.CreateBucketIfNotExists(dbConf); err != nil {
		return err
	}

	return tx.Commit()
}
531127
func (s *State) initialize() {
	if s.stepMap != nil {
		return
	}

	s.stepMap = map[string]*Step{}
	s.stepLookup = map[*milo.Step]*Step{}

	name := "steps"
	if s.Execution != nil {
		name = s.Execution.Name
	}
	s.rootStep.initializeStep(s, nil, name, false)
	s.rootStep.LogNameBase = s.LogNameBase
	s.SetCurrentStep(nil)

	// Add our Command parameters, if applicable.
	if exec := s.Execution; exec != nil {
		s.rootStep.Command = &milo.Step_Command{
			CommandLine: exec.Command,
			Cwd:         exec.Dir,
			Environ:     exec.Env,
		}
	}

	var annotatedNow *timestamp.Timestamp
	if !s.Offline {
		annotatedNow = s.now()
	}
	s.rootStep.Start(annotatedNow)
}
35983
func (meta *Meta) Initialize() error {
	// Set Valuer for Meta
	if meta.Valuer == nil {
		setupValuer(meta, meta.FieldName, meta.GetBaseResource().NewStruct())
	}

	if meta.Valuer == nil {
		utils.ExitWithMsg("Meta %v is not supported for resource %v, no `Valuer` configured for it", meta.FieldName, reflect.TypeOf(meta.BaseResource.GetResource().Value))
	}

	// Set Setter for Meta
	if meta.Setter == nil {
		setupSetter(meta, meta.FieldName, meta.GetBaseResource().NewStruct())
	}
	return nil
}
1323780
func (p *Project) initialize(ctx context.Context) error {
	if p.networks != nil {
		if err := p.networks.Initialize(ctx); err != nil {
			return err
		}
	}
	if p.volumes != nil {
		if err := p.volumes.Initialize(ctx); err != nil {
			return err
		}
	}
	return nil
}
696247
func (b *AESGCMBarrier) Initialize(ctx context.Context, key []byte) error {
	// Verify the key size
	min, max := b.KeyLength()
	if len(key) < min || len(key) > max {
		return fmt.Errorf("key size must be %d or %d", min, max)
	}

	// Check if already initialized
	if alreadyInit, err := b.Initialized(ctx); err != nil {
		return err
	} else if alreadyInit {
		return ErrBarrierAlreadyInit
	}

	// Generate encryption key
	encrypt, err := b.GenerateKey()
	if err != nil {
		return errwrap.Wrapf("failed to generate encryption key: {{err}}", err)
	}

	// Create a new keyring, install the keys
	keyring := NewKeyring()
	keyring = keyring.SetMasterKey(key)
	keyring, err = keyring.AddKey(&Key{
		Term:    1,
		Version: 1,
		Value:   encrypt,
	})
	if err != nil {
		return errwrap.Wrapf("failed to create keyring: {{err}}", err)
	}
	return b.persistKeyring(ctx, keyring)
}
40250
func (f *InfraProvider) Initialize(providers context.Providers) error {
	f.providerContext = providers
	return nil
}
397924
func (s *Discovery) Initialize(uris string, _ time.Duration, _ time.Duration, _ map[string]string) error {
	for _, input := range strings.Split(uris, ",") {
		for _, ip := range discovery.Generate(input) {
			entry, err := discovery.NewEntry(ip)
			if err != nil {
				return fmt.Errorf("%s, please check you are using the correct discovery (missing token:// ?)", err.Error())
			}
			s.entries = append(s.entries, entry)
		}
	}

	return nil
}
1256000
func Initialize(xu *xgbutil.XUtil) {
	xevent.MotionNotifyFun(dragStep).Connect(xu, xu.Dummy())
	xevent.ButtonReleaseFun(DragEnd).Connect(xu, xu.Dummy())
}
732029
func (s *Storage) Init() error {
	s.name = "badger"
	s.opts = badger.DefaultOptions
	s.opts.Dir = os.TempDir() + "badger"
	s.opts.ValueDir = os.TempDir() + "badger"
	return nil
}
593571
func (g *Gomo) Initialize(onStart func(glc *GLContext), onStop func(), updateCallback func()) {
	simlog.FuncIn()
	g.onStart = onStart
	g.onStop = onStop
	g.updateCallback = updateCallback
	g.screensize = screensize
	simlog.FuncOut()
}
188613
func (t *SubprocessTest) initialize(ctx context.Context) (err error) {
	// Initialize the context.
	t.Ctx = ctx

	// Set up a temporary directory.
	t.Dir, err = ioutil.TempDir("", "sample_test")
	if err != nil {
		err = fmt.Errorf("TempDir: %v", err)
		return
	}

	// Build/read the mount_sample tool.
	toolContents, err := getToolContents()
	if err != nil {
		err = fmt.Errorf("getTooltoolContents: %v", err)
		return
	}

	// Create a temporary file to hold the contents of the tool.
	toolFile, err := ioutil.TempFile("", "sample_test")
	if err != nil {
		err = fmt.Errorf("TempFile: %v", err)
		return
	}

	defer toolFile.Close()

	// Ensure that it is deleted when we leave.
	toolPath := toolFile.Name()
	defer os.Remove(toolPath)

	// Write out the tool contents and make them executable.
	if _, err = toolFile.Write(toolContents); err != nil {
		err = fmt.Errorf("toolFile.Write: %v", err)
		return
	}

	if err = toolFile.Chmod(0500); err != nil {
		err = fmt.Errorf("toolFile.Chmod: %v", err)
		return
	}

	// Close the tool file to prevent "text file busy" errors below.
	err = toolFile.Close()
	toolFile = nil
	if err != nil {
		err = fmt.Errorf("toolFile.Close: %v", err)
		return
	}

	// Set up basic args for the subprocess.
	args := []string{
		"--type",
		t.MountType,
		"--mount_point",
		t.Dir,
	}

	args = append(args, t.MountFlags...)

	// Set up a pipe for the "ready" status.
	readyReader, readyWriter, err := os.Pipe()
	if err != nil {
		err = fmt.Errorf("Pipe: %v", err)
		return
	}

	defer readyReader.Close()
	defer readyWriter.Close()

	t.MountFiles["ready_file"] = readyWriter

	// Set up inherited files and appropriate flags.
	var extraFiles []*os.File
	for flag, file := range t.MountFiles {
		// Cf. os/exec.Cmd.ExtraFiles
		fd := 3 + len(extraFiles)

		extraFiles = append(extraFiles, file)
		args = append(args, "--"+flag)
		args = append(args, fmt.Sprintf("%d", fd))
	}

	// Set up a command.
	var stderr bytes.Buffer
	mountCmd := exec.Command(toolPath, args...)
	mountCmd.Stderr = &stderr
	mountCmd.ExtraFiles = extraFiles

	// Handle debug mode.
	if *fDebug {
		mountCmd.Stderr = os.Stderr
		mountCmd.Args = append(mountCmd.Args, "--debug")
	}

	// Start the command.
	if err = mountCmd.Start(); err != nil {
		err = fmt.Errorf("mountCmd.Start: %v", err)
		return
	}

	// Launch a goroutine that waits for it and returns its status.
	mountSampleErr := make(chan error, 1)
	go waitForMountSample(mountCmd, mountSampleErr, &stderr)

	// Wait for the tool to say the file system is ready. In parallel, watch for
	// the tool to fail.
	readyChan := make(chan struct{}, 1)
	go waitForReady(readyReader, readyChan)

	select {
	case <-readyChan:
	case err = <-mountSampleErr:
		return
	}

	// TearDown is no responsible for joining.
	t.mountSampleErr = mountSampleErr

	return
}
413509
func Initialize(user, org string) error {
	if user == db.BLANK {
		org = db.BLANK
	}

	disabled := GetAllDefault(org)
	preferences := []interface{}{}

	for _, topic := range disabled {
		preference := db.Topic{
			User:         user,
			Organization: org,
			Ident:        topic.Ident,
			Channels:     topic.Channels,
		}

		preference.PrepareSave()
		preferences = append(preferences, preference)
	}

	if len(preferences) > 0 {
		err, _ := db.Conn.InsertMulti(db.TopicCollection, preferences...)
		return err
	}

	return nil
}
377258
func (ss *Rate) Init(size uint32, halfLife time.Duration) *Rate {
	*ss = Rate{
		keytobucketno: make(map[string]uint32, size),
		buckets:       make([]bucket, size),
		weightHelper:  -math.Ln2 / float64(halfLife.Nanoseconds()),
		halfLife:      halfLife,
	}
	ss.sh.h = make([]uint32, size)
	ss.sh.ss = ss
	heap.Init(&ss.sh)
	for i := uint32(0); i < uint32(size); i++ {
		ss.sh.h[i] = i
		ss.buckets[i].idx = i
	}
	return ss
}
829711
func (u *uploader) init() {
	if u.cfg.Concurrency == 0 {
		u.cfg.Concurrency = DefaultUploadConcurrency
	}
	if u.cfg.PartSize == 0 {
		u.cfg.PartSize = DefaultUploadPartSize
	}
	if u.cfg.MaxUploadParts == 0 {
		u.cfg.MaxUploadParts = MaxUploadParts
	}

	u.bufferPool = sync.Pool{
		New: func() interface{} { return make([]byte, u.cfg.PartSize) },
	}

	// Try to get the total size for some optimizations
	u.initSize()
}
577283
func (eng *Engine) Initialize(conn net.Conn, handlers ...EventHandler) error {
	eng.inject = make(chan func())
	eng.conn = conn
	eng.connection = Connection{C.pn_connection()}
	eng.transport = Transport{C.pn_transport()}
	eng.collector = C.pn_collector()
	eng.handlers = handlers
	eng.running = make(chan struct{})
	eng.timer = time.NewTimer(0)
	eng.traceEvent = envBool("PN_TRACE_EVT")
	if eng.transport.IsNil() || eng.connection.IsNil() || eng.collector == nil {
		eng.free()
		return fmt.Errorf("proton.NewEngine cannot allocate")
	}
	C.pn_connection_collect(eng.connection.pn, eng.collector)
	return nil
}
1281767
func Initialize() error {
	if code := C.Pm_Initialize(); code != 0 {
		return convertToError(code)
	}
	C.Pt_Start(C.int(1), nil, nil)
	return nil
}
310978
func Init(bucket *service.Bucket, objectKey string) *Image {
	return &Image{
		key:    &objectKey,
		bucket: bucket,
		input:  &service.ImageProcessInput{},
	}
}