// Reminder returns the Reminder associated with the provided reminderID.
422836
func (c oauthClient) Reminder(reminderID uint) (wl.Reminder, error) {
	url := fmt.Sprintf(
		"%s/reminders/%d",
		c.apiURL,
		reminderID,
	)

	req, err := c.newGetRequest(url)
	if err != nil {
		return wl.Reminder{}, err
	}

	resp, err := c.do(req)
	if err != nil {
		return wl.Reminder{}, err
	}

	if resp.StatusCode != http.StatusOK {
		return wl.Reminder{}, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusOK)
	}

	reminder := wl.Reminder{}
	err = json.NewDecoder(resp.Body).Decode(&reminder)
	if err != nil {
		return wl.Reminder{}, err
	}
	return reminder, nil
}
290618
func (l *Logger) Notice(format string, a ...interface{}) {
	l.Log(LevelNotice, format, a...)
}
145197
func (s *userServiceImpl) NotifyIdentitiesBeforeDeactivation(ctx context.Context, now func() time.Time) ([]repository.Identity, error) {
	since := now().Add(-s.config.GetUserDeactivationInactivityNotificationPeriodDays()) // remove 'n' days from now (default: 24)
	limit := s.config.GetUserDeactivationFetchLimit()
	identities, err := s.Repositories().Identities().ListIdentitiesToNotifyForDeactivation(ctx, since, limit)
	if err != nil {
		return nil, errs.Wrap(err, "unable to send notification to users before account deactivation")
	}
	// for each identity, send a notification and record the timestamp in a separate transaction.
	// perform the task for each identity in a separate Tx, and just log the error if something wrong happened,
	// but don't stop processing on the rest of the accounts.
	expirationDate := GetExpiryDate(s.config, now)
	// run the notification/record update in a separate routine, with pooling of child routines to avoid
	// sending too many requests at once to the notification service and to the database
	defer ants.Release()
	var wg sync.WaitGroup
	p, err := ants.NewPoolWithFunc(10, func(id interface{}) {
		defer wg.Done()
		identity, ok := id.(repository.Identity)
		// just to make sure that the arg type is valid.
		if !ok {
			log.Error(ctx, map[string]interface{}{}, "argument is not an identity")
			return
		}
		err := s.notifyIdentityBeforeDeactivation(ctx, identity, expirationDate, now)
		if err != nil {
			log.Error(ctx, map[string]interface{}{
				"error":    err,
				"username": identity.Username,
			}, "error while notifying user before account deactivation")
		} else {
			log.Info(ctx, map[string]interface{}{
				"username": identity.Username,
			}, "notified user before account deactivation")
		}
		// include a small delay to give time to notification service and database to handle the requests
		time.Sleep(s.config.GetPostDeactivationNotificationDelayMillis())
	})
	if err != nil {
		return nil, errs.Wrap(err, "unable to send notification to users before account deactivation")
	}

	defer func() {
		err := p.Release()
		if err != nil {
			log.Error(ctx, map[string]interface{}{
				"error": err,
			}, "error while releasing the go routine pool")
		}
	}()
	for _, identity := range identities {
		wg.Add(1)
		err := p.Invoke(identity)
		if err != nil {
			log.Error(ctx, map[string]interface{}{
				"error": err,
			}, "error while notifying about account deactivation")
		}
	}
	wg.Wait()
	return identities, nil
}
582385
func (b *Broadcaster) Notify(instance interface{}) {
	b.listenerLock.RLock()
	listeners := b.listeners
	b.listenerLock.RUnlock()
	for _, listener := range listeners {
		listener.OnUpdate(instance)
	}
}
188438
func (s *TranslateFile) WriteNotify() <-chan struct{} {
	s.mu.RLock()
	ch := s.writeNotify
	s.mu.RUnlock()
	return ch
}
288458
func Notify(ctx context.Context, subj, msg string) error {
	return errors.Errorf("GOOS %s not yet supported", runtime.GOOS)
}
1340167
func Notice(format string, values ...interface{}) {
	if lvl() <= NoticeLevel {
		logger.Logf("[NOTICE]   "+format, values...)
	}
}
741841
func (c *BitcoindClient) NotifyReceived(addrs []btcutil.Address) error {
	c.NotifyBlocks()

	select {
	case c.rescanUpdate <- addrs:
	case <-c.quit:
		return ErrBitcoindClientShuttingDown
	}

	return nil
}
785128
func (w *Watcher) NotifyWhenUpdated(listener Listener, watcher *fsnotify.Watcher) {

	for {
		select {
		case ev := <-watcher.Events:
			if w.rebuildRequired(ev, listener) {
				if w.serial {
					// Serialize listener.Refresh() calls.
					w.notifyMutex.Lock()

					if err := listener.Refresh(); err != nil {
						utils.Logger.Error("Watcher: Listener refresh reported error:", "error", err)
					}
					w.notifyMutex.Unlock()
				} else {
					// Run refresh in parallel
					go func() {
						w.notifyInProcess(listener)
					}()
				}
			}
		case <-watcher.Errors:
			continue
		}
	}
}
1154043
func (s *RemindersService) List() *RemindersListCall {
	var call RemindersListCall
	call.service = s
	return &call
}
1196114
func (mattermost *MattermostNotifier) Notify(messages Messages) bool {
	if !mattermost.Init() {
		return false
	}

	if mattermost.Detailed {
		return mattermost.notifyDetailed(messages)
	}

	return mattermost.notifySimple(messages)
}
278571
func (s *syncServer) notify(sn *SyncNote) {
	s.sessionLock.RLock()
	sessions := s.sessions
	s.sessionLock.RUnlock()
	for _, ss := range sessions {
		ss.addNote(sn)
	}
}
906776
func (c *Cache) removeNotify(u interface{}, notify bool) (err error) {

	c.Lock()
	defer c.Unlock()

	val, ok := c.data[u]
	if !ok {
		return errors.New("not found")
	}

	if val.timer != nil {
		val.timer.Stop()
	}

	if notify && val.expirer != nil {
		val.expirer(c, u, val.value)
	}

	delete(c.data, u)

	return nil
}
1274270
func (c *RemindersInfoCall) ValidateArgs() error {
	if len(c.reminder) <= 0 {
		return errors.New(`required field reminder not initialized`)
	}
	return nil
}
685948
func (pd *PagerDutyNotifier) Notify(messages Messages) bool {

	client := gopherduty.NewClient(pd.ServiceKey)

	if pd.MaxRetry != 0 {
		client.MaxRetry = pd.MaxRetry

		if pd.RetryBaseInterval != 0 {
			client.RetryBaseInterval = pd.RetryBaseInterval
		} else {
			client.RetryBaseInterval = defaultRetryBaseInterval
		}
	}

	result := true

	for _, message := range messages {
		incidentKey := message.Node
		if message.ServiceId != "" {
			incidentKey += ":" + message.ServiceId
		}
		incidentKey += ":" + message.CheckId
		subject := message.Node
		if message.Service != "" {
			subject += ":" + message.Service
		}
		if message.Check != "" {
			subject += ":" + message.Check
		}
		var response *gopherduty.PagerDutyResponse
		switch {
		case message.IsPassing():
			description := subject + " is now HEALTHY"
			response = client.Resolve(incidentKey, description, message)
		case message.IsWarning():
			description := subject + " is UNSTABLE"
			response = client.Trigger(incidentKey, description, pd.ClientName, pd.ClientUrl, message)
		case message.IsCritical():
			description := subject + " is CRITICAL"
			response = client.Trigger(incidentKey, description, pd.ClientName, pd.ClientUrl, message)
		}

		if response.HasErrors() {
			for _, err := range response.Errors {
				log.Printf("Error sending %s notification to pagerduty: %s\n", incidentKey, err)
			}
			result = false
		}
	}

	log.Println("PagerDuty notification complete")
	return result
}
191711
func (c oauthClient) UpdateReminder(reminder wl.Reminder) (wl.Reminder, error) {
	body, err := json.Marshal(reminder)
	if err != nil {
		return wl.Reminder{}, err
	}

	url := fmt.Sprintf(
		"%s/reminders/%d",
		c.apiURL,
		reminder.ID,
	)

	req, err := c.newPatchRequest(url, body)
	if err != nil {
		return wl.Reminder{}, err
	}

	resp, err := c.do(req)
	if err != nil {
		return wl.Reminder{}, err
	}

	if resp.StatusCode != http.StatusOK {
		return wl.Reminder{}, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusOK)
	}

	returnedReminder := wl.Reminder{}
	err = json.NewDecoder(resp.Body).Decode(&returnedReminder)
	if err != nil {
		return wl.Reminder{}, err
	}
	return returnedReminder, nil
}
110552
func (c *Client) SendNotify(route string, data []byte) error {
	_, err := c.sendMsg(message.Notify, route, data)
	return err
}