// Success is an event fired when a request successfully completed.
//
// https://developer.mozilla.org/docs/Web/Reference/Events/success_indexedDB
767246
func Success(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "success", Listener: listener}
}
312013
func (r *PropResult) Success() bool {
	return r.Status == PropTrue || r.Status == PropProof
}
1256316
func (f *BatchFuture) Results() (uint64, error) {
	<-f.waitCh
	return f.index, f.err
}
352282
func (r *BulkResponse) Succeeded() []*BulkResponseItem {
	if r.Items == nil {
		return nil
	}
	succeeded := make([]*BulkResponseItem, 0)
	for _, item := range r.Items {
		for _, result := range item {
			if result.Status >= 200 && result.Status <= 299 {
				succeeded = append(succeeded, result)
			}
		}
	}
	return succeeded
}
37842
func (c *Context) Success(name string) {
	c.HTML(http.StatusOK, name)
}
214989
func (r Result) Error() string {
	var errIds []string
	var errStr string
	for id, workloadResult := range r {
		if workloadResult.Status == ReleaseStatusFailed {
			errIds = append(errIds, id.String())
			errStr = workloadResult.Error
		}
	}
	switch {
	case len(errIds) == 0:
		return ""
	case len(errIds) == 1:
		return fmt.Sprintf("%s failed: %s", errIds[0], errStr)
	default:
		return fmt.Sprintf("Multiple workloads failed: %s", strings.Join(errIds, ", "))
	}
}
775243
func (t *entryT) Successf(format string, args ...interface{}) {
	t.Put(Passed, fmt.Sprintf(format, args...))
}
316053
func (w *window) Successes() int64 {
	w.bucketLock.RLock()

	var successes int64
	w.buckets.Do(func(x interface{}) {
		b := x.(*bucket)
		successes += b.success
	})
	w.bucketLock.RUnlock()
	return successes
}
1111120
func (tn *TreeNode) processResult(client curator.CuratorFramework, evt curator.CuratorEvent) error {
	tn.tree.logger.Debugf("ProcessResult: %v", evt)
	newStat := evt.Stat()
	switch evt.Type() {
	case curator.EXISTS:
		if tn.parent != nil {
			tn.tree.handleException(errors.New("unexpected EXISTS on non-root node"))
		}
		if evt.Err() == nil {
			tn.state.CompareAndSwap(NodeStateDEAD, NodeStatePENDING)
			tn.wasCreated()
		}
	case curator.CHILDREN:
		switch evt.Err() {
		case zk.ErrNoNode:
			tn.wasDeleted()
		case nil:
			tn.Lock()
			oldChildData := tn.childData
			if oldChildData != nil && oldChildData.Stat().Mzxid == newStat.Mzxid {
				// Only update stat if mzxid is same, otherwise we might obscure
				// GET_DATA event updates.
				tn.childData.SetStat(newStat)
			}
			tn.Unlock()

			if len(evt.Children()) == 0 {
				break
			}
			// Present new children in sorted order for test determinism.
			children := sort.StringSlice(evt.Children())
			sort.Sort(children)
			for _, child := range children {
				if accepted := tn.tree.selector.AcceptChild(path.Join(tn.path, child)); !accepted {
					continue
				}
				tn.Lock()
				if _, exists := tn.children[child]; !exists {
					fullPath := path.Join(tn.path, child)
					node := NewTreeNode(tn.tree, fullPath, tn)
					tn.children[child] = node
					node.wasCreated()
				}
				tn.Unlock()
			}
		}
	case curator.GET_DATA:
		switch evt.Err() {
		case zk.ErrNoNode:
			tn.wasDeleted()
		case nil:
			newChildData := NewChildData(evt.Path(), newStat, evt.Data())
			oldChildData := tn.ChildData()
			if tn.tree.cacheData {
				tn.SwapChildData(newChildData)
			} else {
				tn.SwapChildData(NewChildData(evt.Path(), newStat, nil))
			}

			var added bool
			if tn.parent == nil {
				// We're the singleton root.
				added = tn.state.Swap(NodeStateLIVE) != NodeStateLIVE
			} else {
				added = tn.state.CompareAndSwap(NodeStatePENDING, NodeStateLIVE)
				if !added {
					// Ordinary nodes are not allowed to transition from dead -> live;
					// make sure this isn't a delayed response that came in after death.
					if tn.state.Load() != NodeStateLIVE {
						return nil
					}
				}
			}

			if added {
				tn.tree.publishEvent(TreeCacheEventNodeAdded, newChildData)
			} else {
				if oldChildData == nil || oldChildData.Stat().Mzxid != newStat.Mzxid {
					tn.tree.publishEvent(TreeCacheEventNodeUpdated, newChildData)
				}
			}
		default:
			tn.tree.logger.Printf("Unknown GET_DATA event[%v]: %s", evt.Path(), evt.Err())
		}
	default:
		// An unknown event, probably an error of some sort like connection loss.
		tn.tree.logger.Printf("Unknown event: %v", evt)
		// Don't produce an initialized event on error; reconnect can fix this.
		atomic.AddUint64(&tn.tree.outstandingOps, ^uint64(0))

		return nil
	}

	// Decrease by 1
	if atomic.AddUint64(&tn.tree.outstandingOps, ^uint64(0)) == 0 {
		if !tn.tree.isInitialized.IsSet() {
			tn.tree.isInitialized.Set()
			tn.tree.publishEvent(TreeCacheEventInitialized, nil)
		}
	}
	return nil
}
1113560
func (c *events) Get(name string) (result *api.Event, err error) {
	result = &api.Event{}
	err = c.client.Get().
		Namespace(c.ns).
		Resource("events").
		Name(name).
		Do().
		Into(result)
	return
}
242158
func (c *Context) postEvent(events ...types.BaseEvent) {
	m := Map.EventManager()
	c.WithLock(m, func() {
		for _, event := range events {
			m.PostEvent(c, &types.PostEvent{EventToPost: event})
		}
	})
}
1144497
func (s *Service) Succeed(id int64, apisucceedrequestbodymessage *ApiSucceedRequestBodyMessage) *SucceedCall {
	c := &SucceedCall{s: s, urlParams_: make(gensupport.URLParams)}
	c.id = id
	c.apisucceedrequestbodymessage = apisucceedrequestbodymessage
	return c
}
1200007
func Progress(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "progress", Listener: listener}
}
671586
func processEventQueue(xu *xgbutil.XUtil, pingBefore, pingAfter chan struct{}) {
	for !Empty(xu) {
		if Quitting(xu) {
			return
		}

		// We send the ping *before* the next event is dequeued.
		// This is so the queue doesn't present a misrepresentation of which
		// events haven't been processed yet.
		if pingBefore != nil && pingAfter != nil {
			pingBefore <- struct{}{}
		}
		ev, err := Dequeue(xu)

		// If we gobbled up an error, send it to the error event handler
		// and move on the next event/error.
		if err != nil {
			ErrorHandlerGet(xu)(err)
			if pingBefore != nil && pingAfter != nil {
				pingAfter <- struct{}{}
			}
			continue
		}

		// We know there isn't an error. If there isn't an event either,
		// then there's a bug somewhere.
		if ev == nil {
			xgbutil.Logger.Fatal("BUG: Expected an event but got nil.")
		}

		hooks := getHooks(xu)
		for _, hook := range hooks {
			if !hook.Run(xu, ev) {
				goto END
			}
		}

		switch event := ev.(type) {
		case xproto.KeyPressEvent:
			e := KeyPressEvent{&event}

			// If we're redirecting key events, this is the place to do it!
			if wid := RedirectKeyGet(xu); wid > 0 {
				e.Event = wid
			}

			xu.TimeSet(e.Time)
			runCallbacks(xu, e, KeyPress, e.Event)
		case xproto.KeyReleaseEvent:
			e := KeyReleaseEvent{&event}

			// If we're redirecting key events, this is the place to do it!
			if wid := RedirectKeyGet(xu); wid > 0 {
				e.Event = wid
			}

			xu.TimeSet(e.Time)
			runCallbacks(xu, e, KeyRelease, e.Event)
		case xproto.ButtonPressEvent:
			e := ButtonPressEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, ButtonPress, e.Event)
		case xproto.ButtonReleaseEvent:
			e := ButtonReleaseEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, ButtonRelease, e.Event)
		case xproto.MotionNotifyEvent:
			e := MotionNotifyEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, MotionNotify, e.Event)
		case xproto.EnterNotifyEvent:
			e := EnterNotifyEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, EnterNotify, e.Event)
		case xproto.LeaveNotifyEvent:
			e := LeaveNotifyEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, LeaveNotify, e.Event)
		case xproto.FocusInEvent:
			e := FocusInEvent{&event}
			runCallbacks(xu, e, FocusIn, e.Event)
		case xproto.FocusOutEvent:
			e := FocusOutEvent{&event}
			runCallbacks(xu, e, FocusOut, e.Event)
		case xproto.KeymapNotifyEvent:
			e := KeymapNotifyEvent{&event}
			runCallbacks(xu, e, KeymapNotify, NoWindow)
		case xproto.ExposeEvent:
			e := ExposeEvent{&event}
			runCallbacks(xu, e, Expose, e.Window)
		case xproto.GraphicsExposureEvent:
			e := GraphicsExposureEvent{&event}
			runCallbacks(xu, e, GraphicsExposure, xproto.Window(e.Drawable))
		case xproto.NoExposureEvent:
			e := NoExposureEvent{&event}
			runCallbacks(xu, e, NoExposure, xproto.Window(e.Drawable))
		case xproto.VisibilityNotifyEvent:
			e := VisibilityNotifyEvent{&event}
			runCallbacks(xu, e, VisibilityNotify, e.Window)
		case xproto.CreateNotifyEvent:
			e := CreateNotifyEvent{&event}
			runCallbacks(xu, e, CreateNotify, e.Parent)
		case xproto.DestroyNotifyEvent:
			e := DestroyNotifyEvent{&event}
			runCallbacks(xu, e, DestroyNotify, e.Window)
		case xproto.UnmapNotifyEvent:
			e := UnmapNotifyEvent{&event}
			runCallbacks(xu, e, UnmapNotify, e.Window)
		case xproto.MapNotifyEvent:
			e := MapNotifyEvent{&event}
			runCallbacks(xu, e, MapNotify, e.Event)
		case xproto.MapRequestEvent:
			e := MapRequestEvent{&event}
			runCallbacks(xu, e, MapRequest, e.Window)
			runCallbacks(xu, e, MapRequest, e.Parent)
		case xproto.ReparentNotifyEvent:
			e := ReparentNotifyEvent{&event}
			runCallbacks(xu, e, ReparentNotify, e.Window)
		case xproto.ConfigureNotifyEvent:
			e := ConfigureNotifyEvent{&event}
			runCallbacks(xu, e, ConfigureNotify, e.Window)
		case xproto.ConfigureRequestEvent:
			e := ConfigureRequestEvent{&event}
			runCallbacks(xu, e, ConfigureRequest, e.Window)
			runCallbacks(xu, e, ConfigureRequest, e.Parent)
		case xproto.GravityNotifyEvent:
			e := GravityNotifyEvent{&event}
			runCallbacks(xu, e, GravityNotify, e.Window)
		case xproto.ResizeRequestEvent:
			e := ResizeRequestEvent{&event}
			runCallbacks(xu, e, ResizeRequest, e.Window)
		case xproto.CirculateNotifyEvent:
			e := CirculateNotifyEvent{&event}
			runCallbacks(xu, e, CirculateNotify, e.Window)
		case xproto.CirculateRequestEvent:
			e := CirculateRequestEvent{&event}
			runCallbacks(xu, e, CirculateRequest, e.Window)
		case xproto.PropertyNotifyEvent:
			e := PropertyNotifyEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, PropertyNotify, e.Window)
		case xproto.SelectionClearEvent:
			e := SelectionClearEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, SelectionClear, e.Owner)
		case xproto.SelectionRequestEvent:
			e := SelectionRequestEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, SelectionRequest, e.Requestor)
		case xproto.SelectionNotifyEvent:
			e := SelectionNotifyEvent{&event}
			xu.TimeSet(e.Time)
			runCallbacks(xu, e, SelectionNotify, e.Requestor)
		case xproto.ColormapNotifyEvent:
			e := ColormapNotifyEvent{&event}
			runCallbacks(xu, e, ColormapNotify, e.Window)
		case xproto.ClientMessageEvent:
			e := ClientMessageEvent{&event}
			runCallbacks(xu, e, ClientMessage, e.Window)
		case xproto.MappingNotifyEvent:
			e := MappingNotifyEvent{&event}
			runCallbacks(xu, e, MappingNotify, NoWindow)
		case shape.NotifyEvent:
			e := ShapeNotifyEvent{&event}
			runCallbacks(xu, e, ShapeNotify, e.AffectedWindow)
		default:
			if event != nil {
				xgbutil.Logger.Printf("ERROR: UNSUPPORTED EVENT TYPE: %T",
					event)
			}
		}

	END:

		if pingBefore != nil && pingAfter != nil {
			pingAfter <- struct{}{}
		}
	}
}
1348097
func (rb *ResultBuilder) Results() Results {
	return &results{
		query: rb.Query,
		proc:  rb.Process,
		res:   rb.Output,
	}
}
618798
func (a *action) Finish(results ActionResults) (Action, error) {
	return a.removeAndLog(results.Status, results.Results, results.Message)
}
820610
func JobFinishedEvent(payload string, didSucceed bool) {
	value := 0
	if didSucceed {
		value = 1
	}
	log.GaugeIntD(jobFinished, value, M{
		"payload": payload,
		"success": didSucceed,
	})
}