// Register registers a new service with the registry. If the service
// already exists it updates the service with the new information, otherwise
// it creates a new service.
178494
func (r *Registry) Register(
	puID string,
	pu *policy.PUInfo,
	puContext *pucontext.PUContext,
	secrets secrets.Secrets,
) (*ServiceContext, error) {

	r.Lock()
	defer r.Unlock()

	sctx := &ServiceContext{
		PU:                    pu,
		PUContext:             puContext,
		dependentServiceCache: servicecache.NewTable(),
		RootCA:                [][]byte{},
	}

	// Delete all old references first. Since the registry is locked
	// nobody will be affected.
	r.indexByPort.DeleteByID(puID, true)
	r.indexByPort.DeleteByID(puID, false)

	if err := r.updateDependentServices(sctx); err != nil {
		return nil, err
	}

	if err := r.updateExposedServices(sctx, secrets); err != nil {
		return nil, err
	}

	r.indexByName[puID] = sctx

	return sctx, nil
}
94267
func Register(name string, dsInit DatastoreInit, dsVersion DatastoreVersion) error {
	lock.Lock()
	defer lock.Unlock()
	if _, exists := datastores[name]; exists {
		return fmt.Errorf("Datastore provider %q is already registered", name)
	}
	datastores[name] = dsInit

	if _, exists := datastoreVersions[name]; exists {
		return fmt.Errorf("Datastore provider's %q version function already registered", name)
	}
	datastoreVersions[name] = dsVersion
	return nil
}
614705
func Register(r transport.RouteTable, rs []transport.Procedure) {
	r.Register(rs)
}
1355846
func (f *Factory) Register(componentName string, constructor Constructor) error {
	if _, exists := f.registry[componentName]; exists {
		return fmt.Errorf("Registry error: component '%s' already registered", componentName)
	}
	f.registry[componentName] = registryEntry{
		Constructor: constructor,
		Info: ComponentInfo{
			Name: componentName,
		},
	}
	return nil
}
1351334
func Register(r types.ConfigRegistration) {
	registrationsRWL.Lock()
	defer registrationsRWL.Unlock()
	for x, rr := range registrations {
		if rr.Name() == r.Name() {
			registrations[x] = r
			return
		}
	}
	registrations = append(registrations, r)
}
313784
func Register(app *gramework.App, serviceName ...string) error {
	var m Middleware
	name := os.Args[0]
	if len(serviceName) > 0 {
		name = serviceName[0]
	}

	hostname, err := os.Hostname()
	if err != nil {
		return err
	}

	m.httpReqCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "gramework_http_requests_total",
			Help: "Total count of HTTP requests processed, partitioned by code, method, path and type (HTTP/HTTPS)",
			ConstLabels: prometheus.Labels{
				"service": name,
				"node":    hostname,
			},
		},
		[]string{"code", "method", "path", "type"},
	)
	if err = prometheus.Register(m.httpReqCounter); err != nil {
		return err
	}

	m.reqDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name: "gramework_http_requests_duration_seconds",
			Help: "Request processing duration, partitioned by code, method, path and type (HTTP/HTTPS)",
			ConstLabels: prometheus.Labels{
				"service": name,
				"node":    hostname,
			},
		},
		[]string{"code", "method", "path", "type"},
	)

	if err = prometheus.Register(m.reqDuration); err != nil {
		return err
	}

	app.GET(string(metricsPath), gramework.NewGrameHandler(promhttp.Handler()))

	if err = app.UsePre(m.startReq); err != nil {
		return err
	}

	return app.UseAfterRequest(m.endReq)
}
620308
func Register(v interface{}, args ...string) {
	var (
		t = tryDereference(v)
		p = path.Join(args...)
	)
	mu.Lock()
	defer mu.Unlock()
	if et, ok := registry[t]; ok {
		if et != p {
			panic(errors.Errorf("type registred with alternate path %q != %q", et, p))
		}
		return
	}
	registry[t] = p
}
1077183
func Register(rk string, f Formatter) {
	if rk == "" {
		panic("cannot register empty key")
	}

	registry.Lock()
	defer registry.Unlock()

	if _, ok := registry.r[rk]; ok {
		panic(fmt.Errorf("key %q is already registered", rk))
	}
	if registry.r == nil {
		registry.r = map[string]Formatter{}
	}
	registry.r[rk] = f
}
1264845
func (h *HandlerService) Register(comp component.Component, opts []component.Option) error {
	s := component.NewService(comp, opts)

	if _, ok := h.services[s.Name]; ok {
		return fmt.Errorf("handler: service already defined: %s", s.Name)
	}

	if err := s.ExtractHandler(); err != nil {
		return err
	}

	// register all handlers
	h.services[s.Name] = s
	for name, handler := range s.Handlers {
		handlers[fmt.Sprintf("%s.%s", s.Name, name)] = handler
	}
	return nil
}
793159
func (s *Server) Register(id interface{}, f interface{}) {
	switch f.(type) {
	case func([]interface{}):
	case func([]interface{}) interface{}:
	case func([]interface{}) []interface{}:
	default:
		panic(fmt.Sprintf("function id %v: definition of function is invalid", id))
	}

	if _, ok := s.functions[id]; ok {
		panic(fmt.Sprintf("function id %v: already registered", id))
	}

	s.functions[id] = f
}
1073261
func (c *Client) Register(procedure string, fn MethodHandler, options map[string]interface{}) error {
	id := NewID()
	c.registerListener(id)
	register := &Register{
		Request:   id,
		Options:   options,
		Procedure: URI(procedure),
	}
	if err := c.Send(register); err != nil {
		return err
	}

	// wait to receive REGISTERED message
	msg, err := c.waitOnListener(id)
	if err != nil {
		return err
	} else if e, ok := msg.(*Error); ok {
		return fmt.Errorf("error registering procedure '%v': %v", procedure, e.Error)
	} else if registered, ok := msg.(*Registered); !ok {
		return fmt.Errorf(formatUnexpectedMessage(msg, REGISTERED))
	} else {
		// register the event handler with this registration
		c.procedures[registered.Registration] = &procedureDesc{procedure, fn}
	}
	return nil
}
421114
func (ovs *OvsdbClient) Register(handler NotificationHandler) {
	ovs.handlersMutex.Lock()
	defer ovs.handlersMutex.Unlock()
	ovs.handlers = append(ovs.handlers, handler)
}
858904
func (n *Namespaces) Register(namespace *Namespace, q *WriteOptions) (*WriteMeta, error) {
	wm, err := n.client.write("/v1/namespace", namespace, nil, q)
	if err != nil {
		return nil, err
	}
	return wm, nil
}
383857
func (s *Discovery) Register(addr string) error {
	s.mu.Lock()
	s.values = append(s.values, addr)
	s.mu.Unlock()
	return nil
}
607179
func (c *Client) Register(id, addr string) (*Response, error) {
	m := map[string]string{
		"addr": addr,
	}

	url := c.registrationURL(c.url, id)
	client := &http.Client{}
	client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
		return http.ErrUseLastResponse
	}

	for {
		b, err := json.Marshal(m)
		if err != nil {
			return nil, err
		}

		c.logger.Printf("discovery client attempting registration of %s at %s", addr, url)
		resp, err := client.Post(url, "application-type/json", bytes.NewReader(b))
		if err != nil {
			return nil, err
		}
		defer resp.Body.Close()

		b, err = ioutil.ReadAll(resp.Body)
		if err != nil {
			return nil, err
		}

		switch resp.StatusCode {
		case http.StatusOK:
			r := &Response{}
			if err := json.Unmarshal(b, r); err != nil {
				return nil, err
			}
			c.logger.Printf("discovery client successfully registered %s at %s", addr, url)
			return r, nil
		case http.StatusMovedPermanently:
			url = resp.Header.Get("location")
			c.logger.Println("discovery client redirecting to", url)
			continue
		default:
			return nil, errors.New(resp.Status)
		}
	}
}
963346
func (TriggersNotSupported) Register(context.Context, Transaction, TriggerConfig) (TriggerHandle, error) {
	return nil, triggersNotSupportedError()
}
84270
func (kv *KV) Register(table []byte) error {
	if len(table) == 0 {
		return gkv.ErrTableName
	}
	kv.table = table
	return kv.db.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists(table)
		if err != nil {
			return fmt.Errorf("CreateBucketIfNotExists error: %s",
				err.Error())
		}
		return nil
	})
}