// Registed 返回所有已注册的 writer 名称
438385
func Registed() []string {
	names := make([]string, 0, len(funs))
	for name := range funs {
		names = append(names, name)
	}

	return names
}
728210
func (conn *gdbConn) writeRegister(threadID string, regnum int, data []byte) error {
	if !conn.threadSuffixSupported {
		if err := conn.selectThread('g', threadID, "registers write"); err != nil {
			return err
		}
	}
	conn.outbuf.Reset()
	fmt.Fprintf(&conn.outbuf, "$P%x=", regnum)
	for _, b := range data {
		fmt.Fprintf(&conn.outbuf, "%02x", b)
	}
	conn.appendThreadSelector(threadID)
	_, err := conn.exec(conn.outbuf.Bytes(), "register write")
	return err
}
624060
func (c *Client) Registrations() (r []contract.Registration, err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	objects, err := getObjectsByRange(conn, db.ExportCollection, 0, -1)
	if err != nil {
		return nil, err
	}

	r = make([]contract.Registration, len(objects))
	for i, object := range objects {
		err = json.Unmarshal(object, &r[i])
		if err != nil {
			return nil, err
		}
	}

	return r, err
}
1177622
func (s *User) SetRegisteredOn(v time.Time) *User {
	s.RegisteredOn = &v
	return s
}
272614
func (s *Restore) Registration(idx uint64, req *structs.RegisterRequest) error {
	if err := s.store.ensureRegistrationTxn(s.tx, idx, req); err != nil {
		return err
	}
	return nil
}
678358
func RegisteredCmdMethods() []string {
	registerLock.Lock()
	defer registerLock.Unlock()

	methods := make([]string, 0, len(methodToInfo))
	for k := range methodToInfo {
		methods = append(methods, k)
	}

	sort.Sort(sort.StringSlice(methods))
	return methods
}
683778
func markRegistered(component, part string) bool {
	parts, ok := registered[component]
	if !ok {
		parts = set.NewStrings()
		registered[component] = parts
	}
	if parts.Contains(part) {
		return false
	}
	parts.Add(part)
	return true
}
1323242
func (service *Service) ProcessRegistrationForm(w http.ResponseWriter, r *http.Request) {
	response := struct {
		Redirecturl string `json:"redirecturl"`
		Error       string `json:"error"`
	}{}
	values := struct {
		Firstname       string `json:"firstname"`
		Lastname        string `json:"lastname"`
		Email           string `json:"email"`
		Phonenumber     string `json:"phonenumber"`
		PhonenumberCode string `json:"phonenumbercode"`
		Password        string `json:"password"`
		RedirectParams  string `json:"redirectparams"`
		LangKey         string `json:"langkey"`
	}{}
	if err := json.NewDecoder(r.Body).Decode(&values); err != nil {
		log.Debug("Error decoding the registration request:", err)
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	registrationSession, err := service.GetSession(r, SessionForRegistration, "registrationdetails")
	if err != nil {
		log.Error("Failed to retrieve registration session: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	if registrationSession.IsNew {
		sessions.Save(r, w)
		log.Debug("Registration session expired")
		http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
		return
	}

	sessionKey, _ := registrationSession.Values["sessionkey"].(string)
	if sessionKey == "" {
		log.Debug("Tried to finalize registration but no session key is present")
		sessions.Save(r, w)
		http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
		return
	}

	rMgr := registration.NewManager(r)
	registeringUser, err := rMgr.GetRegisteringUserBySessionKey(sessionKey)
	if err != nil {
		log.Error("Failed to get registration object: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	logMgr := persistentlog.NewManager(r)

	// check if phone number is validated or sms code is provided to validate phone
	phonevalidationkey := registeringUser.PhoneValidationKey

	if isConfirmed, _ := service.phonenumberValidationService.IsConfirmed(r, phonevalidationkey); !isConfirmed {

		logMgr.SaveLog(persistentlog.New(sessionKey, persistentlog.RegistrationFlow, "User tried to register without validated phone"))

		smscode := values.PhonenumberCode
		if smscode == "" {
			log.Debug("no sms code provided and phone not confirmed yet")
			http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
			return
		}

		err = service.phonenumberValidationService.ConfirmRegistrationValidation(r, phonevalidationkey, smscode)
		if err == validation.ErrInvalidCode {
			w.WriteHeader(http.StatusUnprocessableEntity)
			response.Error = "invalid_sms_code"
			json.NewEncoder(w).Encode(&response)
			return
		}
		if err == validation.ErrInvalidOrExpiredKey {
			sessions.Save(r, w)
			http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
			json.NewEncoder(w).Encode(&response)
			return
		}
		if err != nil {
			log.Error("Error while trying to validate phone number in regsitration flow: ", err)
			http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
			return
		}

		logMgr.SaveLog(persistentlog.New(sessionKey, persistentlog.RegistrationFlow, "User confirmed phone number in final registration step"))

	}

	emailvalidationkey := registeringUser.EmailValidationKey
	emailConfirmed, _ := service.emailaddressValidationService.IsConfirmed(r, emailvalidationkey)
	if !emailConfirmed {
		logMgr.SaveLog(persistentlog.New(sessionKey, persistentlog.RegistrationFlow, "User tried to register without validated email"))
		log.Debug("Email not confirmed yet")
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	// We know that the phone number and email address are confirmed. So lets create the actual user
	userMgr := user.NewManager(r)

	// First get the username from the firstname and lastname
	username, err := generateUsername(r, registeringUser.Firstname, registeringUser.Lastname)
	if err != nil {
		log.Error("Failed to generate username: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	// Create the user object
	log.Debug("Creating new user with username ", username)
	userObj := &user.User{
		Username:       username,
		Firstname:      registeringUser.Firstname,
		Lastname:       registeringUser.Lastname,
		EmailAddresses: []user.EmailAddress{{Label: "main", EmailAddress: registeringUser.Email}},
		Phonenumbers:   []user.Phonenumber{{Label: "main", Phonenumber: registeringUser.Phonenumber}},
	}

	err = userMgr.Save(userObj)
	if err != nil {
		log.Error("Failed to create new user: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	// Also give this user a password
	log.Debug("Saving user password")
	passwdMgr := password.NewManager(r)
	err = passwdMgr.Save(username, values.Password)
	if err != nil {
		log.Error("Error while saving the users password: ", err)
		if err.Error() != "internal_error" {
			writeErrorResponse(w, "invalid_password", http.StatusUnprocessableEntity)
		} else {
			http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		}
		return
	}

	// Add correct validated phone number and validated email address
	valMgr := validationdb.NewManager(r)
	p := valMgr.NewValidatedPhonenumber(username, registeringUser.Phonenumber)
	if err = valMgr.SaveValidatedPhonenumber(p); err != nil {
		log.Error("Failed to add validated phone number of new user: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	e := valMgr.NewValidatedEmailAddress(username, registeringUser.Email)
	if err = valMgr.SaveValidatedEmailAddress(e); err != nil {
		log.Error("Failed to add validated email address of new user: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	logMgr.SaveLog(persistentlog.New(sessionKey, persistentlog.RegistrationFlow, "Registration finished, user created"))
	log.Debug("Finished saving new user information")

	// Ideally, we would remove the registration session here as registration is completed.
	// However the login handler checks the existence of this session because it needs the
	// redirectparams as part of the logic to move the user to the requested authenticated page.
	// But this means that if the user immediatly goes back to the registration screen, the old
	// user data is modified as there is already data in the session such as a username. Since we can't
	// remove the session, just empty out al the keys to mimic this process, and then only set the
	// redirectparams

	// Clear registration session
	for key := range registrationSession.Values {
		delete(registrationSession.Values, key)
	}

	// Now set the redirectparams
	registrationSession.Values["redirectparams"] = values.RedirectParams

	sessions.Save(r, w)
	service.loginUser(w, r, username)
}
235767
func (r RuleSet) RegisteredFor(n ast.Node) []Rule {
	if rules, found := r[reflect.TypeOf(n)]; found {
		return rules
	}
	return []Rule{}
}
621879
func (l *LogWriter) RegisterHandler(lh LogHandler) {
	l.Lock()
	defer l.Unlock()

	// Do nothing if already registered
	if _, ok := l.handlers[lh]; ok {
		return
	}

	// Register
	l.handlers[lh] = struct{}{}

	// Send the old logs
	if l.logs[l.index] != "" {
		for i := l.index; i < len(l.logs); i++ {
			lh.HandleLog(l.logs[i])
		}
	}
	for i := 0; i < l.index; i++ {
		lh.HandleLog(l.logs[i])
	}
}
880321
func (mr *MethodRepository) RegisterMethod(method string, h Handler, params, result interface{}) error {
	if method == "" || h == nil {
		return errors.New("jsonrpc: method name and function should not be empty")
	}
	mr.m.Lock()
	mr.r[method] = Metadata{
		Handler: h,
		Params:  params,
		Result:  result,
	}
	mr.m.Unlock()
	return nil
}
1330931
func (f *Formatter) WriteWrapped(str string, a ...interface{}) error {
	if f.Wrap == 0 {
		return f.Write(str, a...)
	}
	text := fmt.Sprintf(str, a...)
	strs := wrapString(text, f.Wrap-f.IndentLevel)
	for _, substr := range strs {
		if err := f.Write(substr); err != nil {
			return err
		}
	}
	return nil
}
251156
func ListRegisteredFunctions() {
	for k, fn := range mappers {
		println(k, "=>", fn.Name)
	}
	for k, fn := range reducers {
		println(k, "=>", fn.Name)
	}
}
1302837
func Register() {
	registerMetrics.Do(func() {
		prometheus.MustRegister(zoneHealth)
		prometheus.MustRegister(zoneSize)
		prometheus.MustRegister(unhealthyNodes)
		prometheus.MustRegister(evictionsNumber)
	})
}
1276716
func (c *ReportingClient) RunFinished(ctx context.Context, args RunFinishedArgs) error {
	return c.postJSON("runfinished", args)
}
1029884
func (writer *baseFileWriter) TimeRotated() bool {
	writer.lock.RLock()
	defer writer.lock.RUnlock()
	return writer.timeRotated
}
1218413
func (h *TextWriter) WriteCreated(w http.ResponseWriter, r *http.Request, location string, e interface{}) {
	w.Header().Set("Location", location)
	h.WriteCode(w, r, http.StatusCreated, e)
}