// SessionState returns either SESSION_CREATED or SESSION_ATTACHED to describe the status of the current websocket session
168554
func (e *sessionMessages) SessionState(ctx context.Context) (string, error) {
	channel := e.SessionMessageChannel("OnConnected")
	defer e.CloseSessionMessageChannel(channel)
	select {
	case <-ctx.Done():
		return "", ctx.Err()
	case message := <-channel:
		connectedInfo := &onConnectedEvent{}
		err := json.Unmarshal(message.Content, connectedInfo)
		if err != nil {
			return "", err
		}
		return connectedInfo.SessionState, nil
	}
}
878079
func (s *LogStream) State(c context.Context) *LogStreamState {
	var lst LogStreamState
	s.PopulateState(c, &lst)
	return &lst
}
212446
func (c *Client) SetState(state imap.ConnState, mailbox *imap.MailboxStatus) {
	c.locker.Lock()
	c.state = state
	c.mailbox = mailbox
	c.locker.Unlock()
}
188559
func (d *Downloader) syncState(root common.Hash) *stateSync {
	s := newStateSync(d, root)
	select {
	case d.stateSyncStart <- s:
	case <-d.quitCh:
		s.err = errCancelStateFetch
		close(s.done)
	}
	return s
}
899373
func (c *ConsulProvider) getState() (uint64, *structs.CAConsulProviderState, error) {
	state := c.Delegate.State()
	idx, providerState, err := state.CAProviderState(c.id)
	if err != nil {
		return 0, nil, err
	}

	if providerState == nil {
		return 0, nil, ErrNotInitialized
	}

	return idx, providerState, nil
}
654592
func (s *TrafficPolicyInstance) SetState(v string) *TrafficPolicyInstance {
	s.State = &v
	return s
}
425472
func (d *Debugger) State(nowait bool) (*api.DebuggerState, error) {
	if d.isRunning() && nowait {
		return &api.DebuggerState{Running: true}, nil
	}

	d.processMutex.Lock()
	defer d.processMutex.Unlock()
	return d.state(nil)
}
546546
func state(c context.Context) []byte {
	return []byte(auth.CurrentUser(c).Identity)
}
1069734
func (c *Client) setState(s uint8) error {
	c.stateLock.Lock()
	err := c.state.Goto(s)
	c.stateLock.Unlock()

	if err != nil {
		return err
	}

	switch s {
	case ConnectedState:
		c.emit(ConnectedEvent, nil)
	case DisconnectedState:
		c.emit(DisconnectedEvent, nil)
	case ClosingState:
		c.emit(ClosingEvent, nil)
	case ClosedState:
		c.emit(ClosedEvent, nil)
	}

	return nil
}
1227243
func (c *Client) saveState() error {
	var wg sync.WaitGroup
	var l sync.Mutex
	var mErr multierror.Error
	runners := c.getAllocRunners()
	wg.Add(len(runners))

	for id, ar := range runners {
		go func(id string, ar AllocRunner) {
			err := c.stateDB.PutAllocation(ar.Alloc())
			if err != nil {
				c.logger.Error("error saving alloc state", "error", err, "alloc_id", id)
				l.Lock()
				multierror.Append(&mErr, err)
				l.Unlock()
			}
			wg.Done()
		}(id, ar)
	}

	wg.Wait()
	return mErr.ErrorOrNil()
}
571603
func IsInState(ctx context.Context, client client.APIClient, containerID string, state ...string) func(log poll.LogT) poll.Result {
	return func(log poll.LogT) poll.Result {
		inspect, err := client.ContainerInspect(ctx, containerID)
		if err != nil {
			return poll.Error(err)
		}
		for _, v := range state {
			if inspect.State.Status == v {
				return poll.Success()
			}
		}
		return poll.Continue("waiting for container to be one of (%s), currently %s", strings.Join(state, ", "), inspect.State.Status)
	}
}
714296
func (s *Disk) SetAttachmentState(v string) *Disk {
	s.AttachmentState = &v
	return s
}
1369141
func NewState(caller base.APICaller, machineTag names.MachineTag) State {
	return &state{
		facade:     base.NewFacadeCaller(caller, "Reboot"),
		machineTag: machineTag,
	}
}
906287
func (gd *GossipDelegate) LocalState(join bool) []byte {
	gd.updateSelfTs()

	// We send our local state of nodeMap
	// The receiver will decide which nodes to merge and which to ignore
	byteLocalState, err := gd.GetLocalStateInBytes()
	if err != nil {
		byteLocalState = []byte{}
	}
	gd.updateGossipTs()
	return byteLocalState
}
772471
func (s *ActivityResponse) SetState(v string) *ActivityResponse {
	s.State = &v
	return s
}
638617
func NewState(caller base.APICaller) *State {
	facadeCaller := base.NewFacadeCaller(caller, deployerFacade)
	return &State{facade: facadeCaller}

}
859710
func (n *Node) state() seesaw.HAState {
	n.statusLock.RLock()
	defer n.statusLock.RUnlock()
	return n.haStatus.State
}