// RegisterFactory allows a client implementation to register itself.
516210
func RegisterFactory(name string, factory Factory) {
	if _, ok := factories[name]; ok {
		log.Fatalf("RegisterFactory: %s already exists", name)
	}
	factories[name] = factory
}
81728
func (ep *EtcdClient) RegisterService(serviceInfo ServiceInfo) error {
	keyName := "/contiv.io/service/" + serviceInfo.ServiceName + "/" +
		serviceInfo.HostAddr + ":" + strconv.Itoa(serviceInfo.Port)
	ttl := time.Duration(serviceInfo.TTL) * time.Second

	log.Infof("Registering service key: %s, value: %+v", keyName, serviceInfo)

	// if there is a previously registered service, stop refreshing it
	if ep.serviceDb[keyName] != nil {
		ep.serviceDb[keyName].stopChan <- true
	}

	// JSON format the object
	jsonVal, err := json.Marshal(serviceInfo)
	if err != nil {
		log.Errorf("Json conversion error. Err %v", err)
		return err
	}

	// create service state
	srvState := etcdServiceState{
		ServiceName: serviceInfo.ServiceName,
		KeyName:     keyName,
		TTL:         ttl,
		HostAddr:    serviceInfo.HostAddr,
		Port:        serviceInfo.Port,
		stopChan:    make(chan bool, 1),
		Hostname:    serviceInfo.Hostname,
	}

	// Run refresh in background
	go ep.refreshService(&srvState, string(jsonVal[:]))

	// Store it in DB
	ep.serviceDb[keyName] = &srvState

	return nil
}
219823
func (wsh *WebsocketHub) registerClient(ch *clientHubSpoke) {
	wsh.clients[ch.c] = ch.cl
	wsh.setNumClients(len(wsh.clients))
	log.Debugf("Registered new websocket client (%d).", wsh.NumClients())
}
484547
func RegisterStreamServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
	return RegisterStreamServiceHandlerClient(ctx, mux, NewStreamServiceClient(conn))
}
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
}
643059
func (wsh *WebsocketHub) RegisterClient(c *hubSpoke, xcChan exchangeChannel) *client {
	cl := new(client)
	wsh.Register <- &clientHubSpoke{cl, c, xcChan}
	return cl
}
384929
func (c *ServiceConfig) RegisterEventHandler(handler ServiceHandler) {
	c.eventHandlers = append(c.eventHandlers, handler)
}
900961
func (pm *PluginManager) RegisterInterface(cfg PluginInterfaceConfig) error {
	// ensure the identifier is unique and hasn't been registered
	// before
	if _, exists := pm.interfaces[cfg.Identifier]; exists {
		return errors.New("Plugin interface already defined")
	}

	if reflect.TypeOf(cfg.Factory).Kind() != reflect.Struct {
		return errors.New("Factory is not a struct")
	}

	// ensure the Factory implements the interface
	if !implements(reflect.TypeOf(cfg.Factory), reflect.TypeOf(cfg.Interface)) {
		return errors.New("Given factory does not implement the registered plugin interface")
	}

	// ensure the Factory implements the goplugin.Plugin interface,
	// which means by extension means the Registered Interface
	// implements the goplugin.Plugin interface
	if _, ok := (cfg.Factory).(Plugin); !ok {
		return errors.New("Defined plugin interface does not implement the goplugin.Plugin interface")
	}

	// load all the method signatures of the interface
	// config
	factory := reflect.TypeOf(cfg.Factory)
	for i := 0; i < factory.NumMethod(); i++ {
		method := factory.Method(i)
		cfg.methods = append(cfg.methods, method.Name)
	}

	// save the plugin interface definition
	pm.interfaces[cfg.Identifier] = cfg
	return nil
}
381498
func (mc MongoClient) AddRegistration(r contract.Registration) (string, error) {
	s := mc.getSessionCopy()
	defer s.Close()

	var mapped models.Registration
	id, err := mapped.FromContract(r)
	if err != nil {
		return "", err
	}

	mapped.TimestampForAdd()

	if err = s.DB(mc.database.Name).C(db.ExportCollection).Insert(mapped); err != nil {
		return "", errorMap(err)
	}
	return id, nil
}
91707
func Register(factoryName string, factory Factory) {
	// Check for duplicates.
	if _, ok := factories[factoryName]; ok {
		panic(fmt.Errorf("duplicate factory name: %v", factoryName))
	}
	factories[factoryName] = factory
}
1218854
func (srv *Instance) RegisterRegistrationProvider(ctx context.Context, wg *sync.WaitGroup, provider registration.RegistrationDataProvider) error {
	return srv.registration.RegisterProvider(ctx, wg, provider)
}
1329483
func RegisterUnannotatedEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
	return RegisterUnannotatedEchoServiceHandlerClient(ctx, mux, NewUnannotatedEchoServiceClient(conn))
}
920122
func (cfg *Config) Register(c context.Context) (output.Output, error) {
	// Validate our configuration parameters.
	switch {
	case cfg.Auth == nil:
		return nil, errors.New("no authenticator supplied")
	case cfg.Host == "":
		return nil, errors.New("no host supplied")
	}
	if err := cfg.Project.Validate(); err != nil {
		return nil, errors.Annotate(err, "failed to validate project").
			InternalReason("project(%v)", cfg.Project).Err()
	}
	if err := cfg.Prefix.Validate(); err != nil {
		return nil, errors.Annotate(err, "failed to validate prefix").
			InternalReason("prefix(%v)", cfg.Prefix).Err()
	}

	// Open a pRPC client to our Coordinator instance.
	httpClient, err := cfg.Auth.Client()
	if err != nil {
		log.WithError(err).Errorf(c, "Failed to get authenticated HTTP client.")
		return nil, err
	}

	// Configure our pRPC client.
	clientOpts := prpc.DefaultOptions()
	clientOpts.PerRPCTimeout = cfg.RPCTimeout
	client := prpc.Client{
		C:       httpClient,
		Host:    cfg.Host,
		Options: clientOpts,
	}

	// If our host begins with "localhost", set insecure option automatically.
	if lhttp.IsLocalHost(cfg.Host) {
		log.Infof(c, "Detected localhost; enabling insecure RPC connection.")
		client.Options.Insecure = true
	}

	// Register our Prefix with the Coordinator.
	log.Fields{
		"prefix": cfg.Prefix,
		"host":   cfg.Host,
	}.Debugf(c, "Registering prefix space with Coordinator service.")

	// Build our source info.
	sourceInfo := make([]string, 0, len(cfg.SourceInfo)+2)
	sourceInfo = append(sourceInfo, cfg.SourceInfo...)
	sourceInfo = append(sourceInfo,
		fmt.Sprintf("GOARCH=%s", runtime.GOARCH),
		fmt.Sprintf("GOOS=%s", runtime.GOOS),
	)

	nonce := make([]byte, types.OpNonceLength)
	if _, err = cryptorand.Read(c, nonce); err != nil {
		log.WithError(err).Errorf(c, "Failed to generate RegisterPrefix nonce.")
		return nil, errors.Annotate(err, "generating nonce").Err()
	}
	req := &api.RegisterPrefixRequest{
		Project:    string(cfg.Project),
		Prefix:     string(cfg.Prefix),
		SourceInfo: sourceInfo,
		Expiration: google.NewDuration(cfg.PrefixExpiration),
		OpNonce:    nonce,
	}

	svc := api.NewRegistrationPRPCClient(&client)
	var resp *api.RegisterPrefixResponse
	err = retry.Retry(c, retry.Default, func() error {
		var err error
		resp, err = svc.RegisterPrefix(c, req)
		return grpcutil.WrapIfTransient(err)
	}, retry.LogCallback(c, "RegisterPrefix"))
	if err != nil {
		log.WithError(err).Errorf(c, "Failed to register prefix with Coordinator service.")
		return nil, err
	}
	log.Fields{
		"prefix":      cfg.Prefix,
		"bundleTopic": resp.LogBundleTopic,
	}.Debugf(c, "Successfully registered log stream prefix.")

	// Validate the response topic.
	fullTopic := ps.Topic(resp.LogBundleTopic)
	if err := fullTopic.Validate(); err != nil {
		log.Fields{
			log.ErrorKey: err,
			"fullTopic":  fullTopic,
		}.Errorf(c, "Coordinator returned invalid Pub/Sub topic.")
		return nil, err
	}

	// Split our topic into project and topic name. This must succeed, since we
	// just finished validating the topic.
	proj, topic := fullTopic.Split()

	// Instantiate our Pub/Sub instance.
	//
	// We will use the non-cancelling context, for all Pub/Sub calls, as we want
	// the Pub/Sub system to drain without interruption if the application is
	// otherwise canceled.
	pctx := cfg.PublishContext
	if pctx == nil {
		pctx = c
	}

	tokenSource, err := cfg.Auth.TokenSource()
	if err != nil {
		log.WithError(err).Errorf(c, "Failed to get TokenSource for Pub/Sub client.")
		return nil, err
	}

	psClient, err := pubsub.NewClient(pctx, proj, option.WithTokenSource(tokenSource))
	if err != nil {
		log.Fields{
			log.ErrorKey: err,
			"project":    proj,
		}.Errorf(c, "Failed to create Pub/Sub client.")
		return nil, errors.New("failed to get Pub/Sub client")
	}
	psTopic := psClient.Topic(topic)

	// We own the prefix and all verifiable parameters have been validated.
	// Successfully return our Output instance.
	//
	// Note that we use our publishing context here.
	return out.New(pctx, out.Config{
		Topic:      pubSubTopicWrapper{psTopic},
		Secret:     resp.Secret,
		Compress:   true,
		Track:      cfg.Track,
		RPCTimeout: cfg.RPCTimeout,
	}), nil
}
1258514
func (s *Service) RegisterHandler(name string, handler Handler) {
	s.handlers[name] = handler
}
601990
func NewFactory(config ...FactoryConfig) *Factory {
	conf := defaultFactoryConfig()
	if len(config) == 1 {
		conf = config[0]
	}

	return &Factory{
		registry: make(map[string]registryEntry, conf.RegistryCapacity),
	}
}
824652
func RegisterTabletManagerClientFactory(name string, factory TabletManagerClientFactory) {
	if _, ok := tabletManagerClientFactories[name]; ok {
		log.Fatalf("RegisterTabletManagerClient %s already exists", name)
	}
	tabletManagerClientFactories[name] = factory
}
932142
func RegisterParserFactory(name string, parserFactory ParserFactory) {
	log.Debugf("proxylib: Registering L7 parser: %v", name)
	parserFactories[name] = parserFactory
}