// See also https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamEventUpdateCallback
354711
func (v *Stream) EventUpdateCallback(events StreamEventType) error {
	var err C.virError
	ret := C.virStreamEventUpdateCallbackWrapper(v.ptr, (C.int)(events), &err)
	if ret == -1 {
		return makeError(&err)
	}

	return nil
}
1154107
func (c *Client) UpdateEvent(e contract.Event) (err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	id := e.ID

	o, err := eventByID(conn, id)
	if err != nil {
		if err == redis.ErrNil {
			return db.ErrNotFound
		}
		return err
	}

	e.Modified = db.MakeTimestamp()
	err = mergo.Merge(&e, o)
	if err != nil {
		return err
	}

	err = deleteEvent(conn, id)
	if err != nil {
		return err
	}

	_, err = addEvent(conn, e)
	return err
}
1089304
func EventUpdateTimeout(timer int, freq int) {
	C.virEventUpdateTimeout((C.int)(timer), (C.int)(freq))
}
1213540
func EventRegisterDefaultImpl() error {
	var err C.virError
	if i := int(C.virEventRegisterDefaultImplWrapper(&err)); i != 0 {
		return makeError(&err)
	}
	return nil
}
529406
func (ctrl *PersistentVolumeController) updateVolumePhaseWithEvent(volume *v1.PersistentVolume, phase v1.PersistentVolumePhase, eventtype, reason, message string) (*v1.PersistentVolume, error) {
	klog.V(4).Infof("updating updateVolumePhaseWithEvent[%s]: set phase %s", volume.Name, phase)
	if volume.Status.Phase == phase {
		// Nothing to do.
		klog.V(4).Infof("updating updateVolumePhaseWithEvent[%s]: phase %s already set", volume.Name, phase)
		return volume, nil
	}

	newVol, err := ctrl.updateVolumePhase(volume, phase, message)
	if err != nil {
		return nil, err
	}

	// Emit the event only when the status change happens, not every time
	// syncClaim is called.
	klog.V(3).Infof("volume %q changed status to %q: %s", volume.Name, phase, message)
	ctrl.eventRecorder.Event(newVol, eventtype, reason, message)

	return newVol, nil
}
643983
func NewSyncedEventStream(stream EventStream) SelectableEventStream {
	var (
		sync syncedEventStream

		in   <-chan Event
		subs <-chan EventWriter
		halt <-chan eventStreamHaltReq
	)

	closeChans := func() func() {
		var (
			inCh   = make(chan Event)
			subsCh = make(chan EventWriter)
			haltCh = make(chan eventStreamHaltReq)
		)

		sync.in, in = inCh, inCh
		sync.subs, subs = subsCh, subsCh
		sync.halt, halt = haltCh, haltCh

		return func() {
			close(inCh)
			close(subsCh)
			close(haltCh)
		}
	}()

	go func() {
		var haltReq eventStreamHaltReq

	communication:
		for {
			select {
			case e := <-in:
				stream.Write(e)

			case w := <-subs:
				stream.Subscribe(w)

			case haltReq = <-halt:
				break communication
			}
		}

		closeChans()
		haltReq.hasHalted <- stream
	}()

	return sync
}
776077
func (r resourceEntry) EventUpdate(oldObject api.StoreObject) api.Event {
	if oldObject != nil {
		return api.EventUpdateResource{Resource: r.Resource, OldResource: oldObject.(resourceEntry).Resource}
	}
	return api.EventUpdateResource{Resource: r.Resource}
}
1129889
func (s *VPNService) UpdateVpnConnection(p *UpdateVpnConnectionParams) (*UpdateVpnConnectionResponse, error) {
	resp, err := s.cs.newRequest("updateVpnConnection", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r UpdateVpnConnectionResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
509354
func (conn *FakeVTGateConn) UpdateStream(ctx context.Context, keyspace string, shard string, keyRange *topodatapb.KeyRange, tabletType topodatapb.TabletType, timestamp int64, event *querypb.EventToken) (vtgateconn.UpdateStreamReader, error) {
	return nil, fmt.Errorf("NYI")
}
928765
func domainEventGenericCallback(c C.virConnectPtr, d C.virDomainPtr,
	opaque int) {

	domain := VirDomain{ptr: d}
	connection := VirConnection{ptr: c}

	callDomainCallbackId(opaque, &connection, &domain, nil)
}
1169219
func (m *MockLambdaAPI) UpdateEventSourceMapping(arg0 *lambda.UpdateEventSourceMappingInput) (*lambda.EventSourceMappingConfiguration, error) {
	ret := m.ctrl.Call(m, "UpdateEventSourceMapping", arg0)
	ret0, _ := ret[0].(*lambda.EventSourceMappingConfiguration)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
531193
func synchronousEvent(c *asticontext.Canceller, l listenable, w *writer, i Event, eventNameDone string) (o Event, err error) {
	o = synchronousFunc(c, l, func() {
		if err = w.write(i); err != nil {
			err = errors.Wrapf(err, "writing %+v event failed", i)
			return
		}
		return
	}, eventNameDone)
	return
}
632533
func (s *Stream) sendWindowUpdate() error {
	s.controlHdrLock.Lock()
	defer s.controlHdrLock.Unlock()

	// Determine the delta update
	max := s.session.config.MaxStreamWindowSize
	var bufLen uint32
	s.recvLock.Lock()
	if s.recvBuf != nil {
		bufLen = uint32(s.recvBuf.Len())
	}
	delta := (max - bufLen) - s.recvWindow

	// Determine the flags if any
	flags := s.sendFlags()

	// Check if we can omit the update
	if delta < (max/2) && flags == 0 {
		s.recvLock.Unlock()
		return nil
	}

	// Update our window
	s.recvWindow += delta
	s.recvLock.Unlock()

	// Send the header
	s.controlHdr.encode(typeWindowUpdate, flags, s.id, delta)
	if err := s.session.waitForSendErr(s.controlHdr, nil, s.controlErr); err != nil {
		return err
	}
	return nil
}
774273
func NewErrorEvent(e ExitCode) *omaha.EventRequest {
	return &omaha.EventRequest{
		Type:      omaha.EventTypeUpdateComplete,
		Result:    omaha.EventResultError,
		ErrorCode: int(e),
	}
}
191530
func (m *MockStreamFlowController) UpdateHighestReceived(arg0 protocol.ByteCount, arg1 bool) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UpdateHighestReceived", arg0, arg1)
	ret0, _ := ret[0].(error)
	return ret0
}
852638
func (cc *Controller) onUpdateNodeEvent(oldObj interface{}, newObj interface{}) {
	newNode, ok := newObj.(*apiv1.Node)
	if !ok {
		utillog.Errorf("failed to cast new object to Node, couldn't handle event")
		return
	}
	if oldObj == nil {
		// Node was just added, need to sync
		utillog.Infof("initial Node watch event")
		cc.pokeConfigSourceWorker()
		return
	}
	oldNode, ok := oldObj.(*apiv1.Node)
	if !ok {
		utillog.Errorf("failed to cast old object to Node, couldn't handle event")
		return
	}
	if !apiequality.Semantic.DeepEqual(oldNode.Spec.ConfigSource, newNode.Spec.ConfigSource) {
		utillog.Infof("Node.Spec.ConfigSource was updated")
		cc.pokeConfigSourceWorker()
	}
}
1315426
func (plugin *ExamplePlugin) asyncEventHandler() {
	plugin.Log.Info("Started Kafka async event handler...")
	msgCounter := 0
	asyncMsgSucc := 0
	if messageCountNum == 0 {
		// Set as done
		plugin.asyncSuccess = true
		plugin.asyncRecv = true
	}
	for {
		select {
		// Channel subscribed with watcher
		case message := <-plugin.asyncSubscription:
			plugin.Log.Infof("Received async Kafka Message, topic '%s', partition '%v', offset '%v', key: '%s', ",
				message.GetTopic(), message.GetPartition(), message.GetOffset(), message.GetKey())
			// mark the offset
			plugin.kafkaWatcher.MarkOffset(message, "")
			msgCounter++
			if msgCounter == messageCountNum {
				plugin.asyncRecv = true
			}
		case message := <-plugin.asyncSuccessChannel:
			plugin.Log.Infof("Async message successfully delivered, topic '%s', partition '%v', offset '%v', key: '%s', ",
				message.GetTopic(), message.GetPartition(), message.GetOffset(), message.GetKey())
			asyncMsgSucc++
			if asyncMsgSucc == messageCountNum {
				plugin.asyncSuccess = true
			}
			// Error callback channel
		case err := <-plugin.asyncErrorChannel:
			plugin.Log.Errorf("Failed to publish async message, %v", err)
		}
	}
}