// step moves the state machine to the next state.
// buf must contain all the data ready for consumption for current state.
// It must not be called when state is done.
512828
func (p *pktLineParser) step() error {
	switch p.state {
	case ready:
		p.state = readingLen
		p.next = pktLenSize
		return nil
	case readingLen:
		// len(p.buf) is 4.
		pktLen, err := parsePktLen(p.buf)
		if err != nil {
			return err
		}

		switch {
		case pktLen == 0:
			p.state = done
			p.next = 0
			p.buf = nil
			return nil
		default:
			p.state = readingPayload
			p.next = pktLen - pktLenSize // (pkt-len - 4)*(OCTET)
			p.buf = p.buf[:0]
			return nil
		}
	case readingPayload:
		p.state = readingLen
		p.next = pktLenSize
		p.Lines = append(p.Lines, string(p.buf))
		p.buf = p.buf[:0]
		return nil
	default:
		panic(fmt.Errorf("unreachable: %v", p.state))
	}
}
376400
func stateStepsFor22() []Step {
	return []Step{
		&upgradeStep{
			description: "add machineid to non-detachable storage docs",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddNonDetachableStorageMachineId()
			},
		},
		&upgradeStep{
			description: "remove application config settings with nil value",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().RemoveNilValueApplicationSettings()
			},
		},
		&upgradeStep{
			description: "add controller log collection sizing config settings",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddControllerLogCollectionsSizeSettings()
			},
		},
		&upgradeStep{
			description: "add status history pruning config settings",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddStatusHistoryPruneSettings()
			},
		},
		&upgradeStep{
			description: "add storage constraints to storage instance docs",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddStorageInstanceConstraints()
			},
		},
		&upgradeStep{
			description: "split log collections",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().SplitLogCollections()
			},
		},
	}
}
1147293
func (s *StepCheckExistingImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
	c := state.Get("config").(*Config)
	d := state.Get("driver").(Driver)
	ui := state.Get("ui").(packer.Ui)

	ui.Say("Checking image does not exist...")
	c.imageAlreadyExists = d.ImageExists(c.ImageName)
	if !c.PackerForce && c.imageAlreadyExists {
		err := fmt.Errorf("Image %s already exists.\n"+
			"Use the force flag to delete it prior to building.", c.ImageName)
		state.Put("error", err)
		ui.Error(err.Error())
		return multistep.ActionHalt
	}
	return multistep.ActionContinue
}
683585
func stateStepsFor254() []Step {
	return []Step{
		&upgradeStep{
			description: "ensure default modification status is set for machines",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().EnsureDefaultModificationStatus()
			},
		},
		&upgradeStep{
			description: "ensure device constraints exists for applications",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().EnsureApplicationDeviceConstraints()
			},
		},
	}
}
49312
func stateStepsFor223() []Step {
	return []Step{
		&upgradeStep{
			description: "add max-action-age and max-action-size config settings",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddActionPruneSettings()
			},
		},
	}
}
440911
func (b *Backoff) Step() time.Duration {
	if b.Steps < 1 {
		if b.Jitter > 0 {
			return Jitter(b.Duration, b.Jitter)
		}
		return b.Duration
	}
	b.Steps--

	duration := b.Duration

	// calculate the next step
	if b.Factor != 0 {
		b.Duration = time.Duration(float64(b.Duration) * b.Factor)
		if b.Cap > 0 && b.Duration > b.Cap {
			b.Duration = b.Cap
			b.Steps = 0
		}
	}

	if b.Jitter > 0 {
		duration = Jitter(duration, b.Jitter)
	}
	return duration
}
447646
func (a *AdafruitMotorHatDriver) Step(motor, steps int, dir AdafruitDirection, style AdafruitStepStyle) (err error) {
	secPerStep := a.stepperMotors[motor].secPerStep
	latestStep := 0
	if style == AdafruitInterleave {
		secPerStep = secPerStep / 2.0
	}
	if style == AdafruitMicrostep {
		secPerStep /= float64(stepperMicrosteps)
		steps *= stepperMicrosteps
	}
	if adafruitDebug {
		log.Printf("[adafruit_driver] %f seconds per step", secPerStep)
	}
	for i := 0; i < steps; i++ {
		if latestStep, err = a.oneStep(motor, dir, style); err != nil {
			return
		}
		time.Sleep(time.Duration(secPerStep) * time.Second)
	}
	// As documented in the Adafruit python driver:
	// This is an edge case, if we are in between full steps, keep going to end on a full step
	if style == AdafruitMicrostep {
		for latestStep != 0 && latestStep != stepperMicrosteps {
			if latestStep, err = a.oneStep(motor, dir, style); err != nil {
				return
			}
			time.Sleep(time.Duration(secPerStep) * time.Second)
		}
	}
	return
}
511698
func (_m *ClusterClient) Step(ctx context.Context, opts ...grpc.CallOption) (orderer.Cluster_StepClient, error) {
	_va := make([]interface{}, len(opts))
	for _i := range opts {
		_va[_i] = opts[_i]
	}
	var _ca []interface{}
	_ca = append(_ca, ctx)
	_ca = append(_ca, _va...)
	ret := _m.Called(_ca...)

	var r0 orderer.Cluster_StepClient
	if rf, ok := ret.Get(0).(func(context.Context, ...grpc.CallOption) orderer.Cluster_StepClient); ok {
		r0 = rf(ctx, opts...)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(orderer.Cluster_StepClient)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, ...grpc.CallOption) error); ok {
		r1 = rf(ctx, opts...)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
135518
func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
	// Custom factory for creating providers.
	concreteProvider := func(a *NodeAbstractProvider) dag.Vertex {
		return &NodeApplyableProvider{
			NodeAbstractProvider: a,
		}
	}

	concreteResource := func(a *NodeAbstractResource) dag.Vertex {
		return &NodeApplyableResource{
			NodeAbstractResource: a,
		}
	}

	concreteOrphanResource := func(a *NodeAbstractResource) dag.Vertex {
		return &NodeDestroyResource{
			NodeAbstractResource: a,
		}
	}

	concreteResourceInstance := func(a *NodeAbstractResourceInstance) dag.Vertex {
		return &NodeApplyableResourceInstance{
			NodeAbstractResourceInstance: a,
		}
	}

	steps := []GraphTransformer{
		// Creates all the resources represented in the config. During apply,
		// we use this just to ensure that the whole-resource metadata is
		// updated to reflect things such as whether the count argument is
		// set in config, or which provider configuration manages each resource.
		&ConfigTransformer{
			Concrete: concreteResource,
			Config:   b.Config,
		},

		// Creates all the resource instances represented in the diff, along
		// with dependency edges against the whole-resource nodes added by
		// ConfigTransformer above.
		&DiffTransformer{
			Concrete: concreteResourceInstance,
			State:    b.State,
			Changes:  b.Changes,
		},

		// Creates extra cleanup nodes for any entire resources that are
		// no longer present in config, so we can make sure we clean up the
		// leftover empty resource states after the instances have been
		// destroyed.
		// (We don't track this particular type of change in the plan because
		// it's just cleanup of our own state object, and so doesn't effect
		// any real remote objects or consumable outputs.)
		&OrphanResourceTransformer{
			Concrete: concreteOrphanResource,
			Config:   b.Config,
			State:    b.State,
		},

		// Create orphan output nodes
		&OrphanOutputTransformer{Config: b.Config, State: b.State},

		// Attach the configuration to any resources
		&AttachResourceConfigTransformer{Config: b.Config},

		// Attach the state
		&AttachStateTransformer{State: b.State},

		// Destruction ordering
		&DestroyEdgeTransformer{
			Config:  b.Config,
			State:   b.State,
			Schemas: b.Schemas,
		},
		GraphTransformIf(
			func() bool { return !b.Destroy },
			&CBDEdgeTransformer{
				Config:  b.Config,
				State:   b.State,
				Schemas: b.Schemas,
			},
		),

		// Provisioner-related transformations
		&MissingProvisionerTransformer{Provisioners: b.Components.ResourceProvisioners()},
		&ProvisionerTransformer{},

		// Add root variables
		&RootVariableTransformer{Config: b.Config},

		// Add the local values
		&LocalTransformer{Config: b.Config},

		// Add the outputs
		&OutputTransformer{Config: b.Config},

		// Add module variables
		&ModuleVariableTransformer{Config: b.Config},

		// add providers
		TransformProviders(b.Components.ResourceProviders(), concreteProvider, b.Config),

		// Remove modules no longer present in the config
		&RemovedModuleTransformer{Config: b.Config, State: b.State},

		// Must attach schemas before ReferenceTransformer so that we can
		// analyze the configuration to find references.
		&AttachSchemaTransformer{Schemas: b.Schemas},

		// Connect references so ordering is correct
		&ReferenceTransformer{},

		// Handle destroy time transformations for output and local values.
		// Reverse the edges from outputs and locals, so that
		// interpolations don't fail during destroy.
		// Create a destroy node for outputs to remove them from the state.
		// Prune unreferenced values, which may have interpolations that can't
		// be resolved.
		GraphTransformIf(
			func() bool { return b.Destroy },
			GraphTransformMulti(
				&DestroyValueReferenceTransformer{},
				&DestroyOutputTransformer{},
				&PruneUnusedValuesTransformer{},
			),
		),

		// Add the node to fix the state count boundaries
		&CountBoundaryTransformer{
			Config: b.Config,
		},

		// Target
		&TargetsTransformer{Targets: b.Targets},

		// Close opened plugin connections
		&CloseProviderTransformer{},
		&CloseProvisionerTransformer{},

		// Single root
		&RootTransformer{},
	}

	if !b.DisableReduce {
		// Perform the transitive reduction to make our graph a bit
		// more sane if possible (it usually is possible).
		steps = append(steps, &TransitiveReductionTransformer{})
	}

	return steps
}
1360847
func (p *Pipeline) step() {
	if p.head == p.tail {
		go func() {
			p.done <- nil
		}()
	} else {
		go func() {
			p.head = p.head.next
			p.next <- nil
		}()
	}
}
167348
func (p *printer) steps(steps []*pb.Step) {
	maxNameWidth := 0
	for _, s := range steps {
		if w := utf8.RuneCountInString(s.Name); w > maxNameWidth {
			maxNameWidth = w
		}
	}

	for _, s := range steps {
		p.f("%sStep ", ansiStatus[s.Status])
		p.fw(maxNameWidth+5, "%q", s.Name)
		p.fw(10, "%s", s.Status)

		// Print duration.
		durString := ""
		if start, err := ptypes.Timestamp(s.StartTime); err == nil {
			var stepDur time.Duration
			if end, err := ptypes.Timestamp(s.EndTime); err == nil {
				stepDur = end.Sub(start)
			} else {
				now := p.nowFn()
				stepDur = now.Sub(start.In(now.Location()))
			}
			durString = truncateDuration(stepDur).String()
		}
		p.fw(10, "%s", durString)

		// Print log names.
		// Do not print log URLs because they are very long and
		// bb has `log` subcommand.
		if len(s.Logs) > 0 {
			p.f("Logs: ")
			for i, l := range s.Logs {
				if i > 0 {
					p.f(", ")
				}
				p.f("%q", l.Name)
			}
		}

		p.f("%s\n", ansi.Reset)

		p.indent.Level += 2
		if s.SummaryMarkdown != "" {
			// TODO(nodir): transform lists of links to look like logs
			p.summary(s.SummaryMarkdown)
		}
		p.indent.Level -= 2
	}
}
668247
func stepsFor245() []Step {
	return []Step{
		&upgradeStep{
			description: "update exec.start.sh log path if incorrect",
			targets:     []Target{AllMachines},
			run:         correctServiceFileLogPath,
		},
	}
}
210186
func (s *StepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
	config := state.Get("config").(*Config)
	driver := state.Get("driver").(Driver)
	ui := state.Get("ui").(packer.Ui)

	if config.PackerForce && config.imageAlreadyExists {
		ui.Say("Deleting previous image...")

		errCh := driver.DeleteImage(config.ImageName)
		err := <-errCh
		if err != nil {
			err := fmt.Errorf("Error deleting image: %s", err)
			state.Put("error", err)
			ui.Error(err.Error())
			return multistep.ActionHalt
		}
	}

	ui.Say("Creating image...")

	imageCh, errCh := driver.CreateImage(
		config.ImageName, config.ImageDescription, config.ImageFamily, config.Zone,
		config.DiskName, config.ImageLabels, config.ImageLicenses)
	var err error
	select {
	case err = <-errCh:
	case <-time.After(config.stateTimeout):
		err = errors.New("time out while waiting for image to register")
	}

	if err != nil {
		err := fmt.Errorf("Error waiting for image: %s", err)
		state.Put("error", err)
		ui.Error(err.Error())
		return multistep.ActionHalt
	}

	state.Put("image", <-imageCh)
	return multistep.ActionContinue
}
1037465
func (f *FakeClock) Step(d time.Duration) {
	f.lock.Lock()
	defer f.lock.Unlock()
	f.setTimeLocked(f.time.Add(d))
}
141327
func stateStepsFor21() []Step {
	return []Step{
		&upgradeStep{
			description: "add attempt to migration docs",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddMigrationAttempt()
			},
		},
		&upgradeStep{
			description: "add sequences to track used local charm revisions",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddLocalCharmSequences()
			},
		},
		&upgradeStep{
			description: "update lxd cloud/credentials",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return updateLXDCloudCredentials(context.State())
			},
		},
	}
}
189805
func (s *State) SetCurrentStep(v *Step) {
	if v == nil {
		v = &s.rootStep
	}
	if v.s != s {
		panic("step is not bound to state")
	}
	s.stepCursor = v
}
84420
func step(dt float32) {
	space.Step(vect.Float(dt))

	for i := 0; i < len(balls); i++ {
		p := balls[i].Body.Position()
		if p.Y < -100 {
			space.RemoveBody(balls[i].Body)
			balls[i] = nil
			balls = append(balls[:i], balls[i+1:]...)
			i-- // consider same index again
		}
	}
}