// GetKeyspace reads the given keyspace and returns it
431660
func (ts *Server) GetKeyspace(ctx context.Context, keyspace string) (*KeyspaceInfo, error) {
	keyspacePath := path.Join(KeyspacesPath, keyspace, KeyspaceFile)
	data, version, err := ts.globalCell.Get(ctx, keyspacePath)
	if err != nil {
		return nil, err
	}

	k := &topodatapb.Keyspace{}
	if err = proto.Unmarshal(data, k); err != nil {
		return nil, vterrors.Wrap(err, "bad keyspace data")
	}

	return &KeyspaceInfo{
		keyspace: keyspace,
		version:  version,
		Keyspace: k,
	}, nil
}
405705
func (c *Cache) GetNamespace(name string) (*services.Namespace, error) {
	return c.presenceCache.GetNamespace(name)
}
104829
func (l *Lock) lockKeyspace(ctx context.Context, ts *Server, keyspace string) (LockDescriptor, error) {
	log.Infof("Locking keyspace %v for action %v", keyspace, l.Action)

	ctx, cancel := context.WithTimeout(ctx, *RemoteOperationTimeout)
	defer cancel()

	span, ctx := trace.NewSpan(ctx, "TopoServer.LockKeyspaceForAction")
	span.Annotate("action", l.Action)
	span.Annotate("keyspace", keyspace)
	defer span.Finish()

	keyspacePath := path.Join(KeyspacesPath, keyspace)
	j, err := l.ToJSON()
	if err != nil {
		return nil, err
	}
	return ts.globalCell.Lock(ctx, keyspacePath, j)
}
386164
func (v *KeyValue_SetValue_Args) GetKey() (o string) {
	if v != nil && v.Key != nil {
		return *v.Key
	}

	return
}
1369314
func (s *PresenceService) GetNamespace(name string) (*services.Namespace, error) {
	if name == "" {
		return nil, trace.BadParameter("missing namespace name")
	}
	item, err := s.Get(context.TODO(), backend.Key(namespacesPrefix, name, paramsPrefix))
	if err != nil {
		if trace.IsNotFound(err) {
			return nil, trace.NotFound("namespace %q is not found", name)
		}
		return nil, trace.Wrap(err)
	}
	return services.UnmarshalNamespace(
		item.Value, services.WithResourceID(item.ID), services.WithExpires(item.Expires))
}
504568
func (p *Plan) GetSpace() int {
	if p == nil || p.Space == nil {
		return 0
	}
	return *p.Space
}
2094
func (kc KeyClosure) GetKey(address btcutil.Address) (*btcec.PrivateKey,
	bool, error) {
	return kc(address)
}
694655
func (s *Session) KeyspaceMetadata(keyspace string) (*KeyspaceMetadata, error) {
	// fail fast
	if s.Closed() {
		return nil, ErrSessionClosed
	} else if keyspace == "" {
		return nil, ErrNoKeyspace
	}

	return s.schemaDescriber.getSchema(keyspace)
}
367247
func (a *Allocator) getAddrSpace(as string) (*addrSpace, error) {
	a.Lock()
	defer a.Unlock()
	aSpace, ok := a.addrSpaces[as]
	if !ok {
		return nil, types.BadRequestErrorf("cannot find address space %s (most likely the backing datastore is not configured)", as)
	}
	return aSpace, nil
}
463258
func (f *jwtFilter) getKey(token *jwt.Token) (interface{}, error) {
	return f.publicKey, nil
}
276757
func GetKeyFromName(name string) Keycode {
	_name := C.CString(name)
	defer C.free(unsafe.Pointer(_name))
	return (Keycode)(C.SDL_GetKeyFromName(_name))
}
1369885
func (s *witServiceImpl) GetSpace(ctx context.Context, spaceID string) (space *wit.Space, e error) {
	remoteWITService, err := s.createClientWithContextSigner(ctx)
	if err != nil {
		return nil, err
	}

	spaceIDUUID, err := uuid.FromString(spaceID)
	if err != nil {
		return nil, err
	}

	res, err := remoteWITService.ShowSpace(ctx, witservice.ShowSpacePath(spaceIDUUID), nil, nil)
	if err != nil {
		return nil, err
	}

	defer rest.CloseResponse(res)
	if res.StatusCode != http.StatusOK {
		bodyString := rest.ReadBody(res.Body)
		log.Error(ctx, map[string]interface{}{
			"spaceId":         spaceID,
			"response_status": res.Status,
			"response_body":   bodyString,
		}, "unable to get space from WIT")
		return nil, errors.Errorf("unable to get space from WIT. Response status: %s. Response body: %s", res.Status, bodyString)
	}

	spaceSingle, err := remoteWITService.DecodeSpaceSingle(res)
	if err != nil {
		return nil, err
	}

	return &wit.Space{
		ID:          *spaceSingle.Data.ID,
		Name:        *spaceSingle.Data.Attributes.Name,
		Description: *spaceSingle.Data.Attributes.Description,
		OwnerID:     *spaceSingle.Data.Relationships.OwnedBy.Data.ID}, nil
}
902921
func (et *ExplainTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) {
	et.Lock.Lock()
	defer et.Lock.Unlock()

	vschema := et.Keyspaces[keyspace]
	if vschema == nil {
		return nil, fmt.Errorf("no vschema for keyspace %s", keyspace)
	}

	var srvKeyspace *topodatapb.SrvKeyspace
	if vschema.Sharded {
		shards := make([]*topodatapb.ShardReference, 0, et.NumShards)
		for i := 0; i < et.NumShards; i++ {
			kr, err := key.EvenShardsKeyRange(i, et.NumShards)
			if err != nil {
				return nil, err
			}

			shard := &topodatapb.ShardReference{
				Name:     key.KeyRangeString(kr),
				KeyRange: kr,
			}
			shards = append(shards, shard)
		}

		srvKeyspace = &topodatapb.SrvKeyspace{
			ShardingColumnName: "", // exact value is ignored
			ShardingColumnType: 0,
			Partitions: []*topodatapb.SrvKeyspace_KeyspacePartition{
				{
					ServedType:      topodatapb.TabletType_MASTER,
					ShardReferences: shards,
				},
				{
					ServedType:      topodatapb.TabletType_REPLICA,
					ShardReferences: shards,
				},
				{
					ServedType:      topodatapb.TabletType_RDONLY,
					ShardReferences: shards,
				},
			},
		}

	} else {
		// unsharded
		kr, err := key.EvenShardsKeyRange(0, 1)
		if err != nil {
			return nil, err
		}

		shard := &topodatapb.ShardReference{
			Name: key.KeyRangeString(kr),
		}

		srvKeyspace = &topodatapb.SrvKeyspace{
			Partitions: []*topodatapb.SrvKeyspace_KeyspacePartition{
				{
					ServedType:      topodatapb.TabletType_MASTER,
					ShardReferences: []*topodatapb.ShardReference{shard},
				},
				{
					ServedType:      topodatapb.TabletType_REPLICA,
					ShardReferences: []*topodatapb.ShardReference{shard},
				},
				{
					ServedType:      topodatapb.TabletType_RDONLY,
					ShardReferences: []*topodatapb.ShardReference{shard},
				},
			},
		}
	}

	return srvKeyspace, nil
}
143657
func (trust *NotarySigner) GetKey(keyid string) data.PublicKey {
	pubKey, _, err := trust.getKeyInfo(keyid)
	if err != nil {
		return nil
	}
	return pubKey
}
1231992
func (v *KeyValue_GetValue_Args) GetKey() (o string) {
	if v != nil && v.Key != nil {
		return *v.Key
	}

	return
}
861291
func (server *ResilientServer) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error) {
	entry := server.getSrvKeyspaceEntry(cell, keyspace)

	// If the watch is already running, return the value
	entry.mutex.RLock()
	if entry.watchState == watchStateRunning {
		v, e := entry.value, entry.lastError
		entry.mutex.RUnlock()
		return v, e
	}
	entry.mutex.RUnlock()

	entry.mutex.Lock()
	defer entry.mutex.Unlock()

	// If the watch is already running (now that we have the write lock),
	// return the value
	if entry.watchState == watchStateRunning {
		return entry.value, entry.lastError
	}

	// Watch is not running. Start a new one if it is time to use it and if
	// there isn't one already one  in the process of being started.
	shouldRefresh := time.Since(entry.lastErrorTime) > server.cacheRefresh
	if shouldRefresh && (entry.watchState == watchStateIdle) {
		entry.watchState = watchStateStarting
		entry.watchStartingChan = make(chan struct{})
		go server.watchSrvKeyspace(ctx, entry, cell, keyspace)
	}

	// If the cached value is still valid, use it. Otherwise wait
	// for the watch attempt to complete to get a more up to date
	// response.
	//
	// In the event that the topo service is slow or unresponsive either
	// on the initial fetch or if the cache TTL expires, then several
	// requests could be blocked waiting for the response to come back.
	cacheValid := entry.value != nil && time.Since(entry.lastValueTime) < server.cacheTTL
	if cacheValid {
		server.counts.Add(cachedCategory, 1)
		return entry.value, nil
	}

	if entry.watchState == watchStateStarting {
		watchStartingChan := entry.watchStartingChan
		entry.mutex.Unlock()
		select {
		case <-watchStartingChan:
		case <-ctx.Done():
			entry.mutex.Lock()
			return nil, fmt.Errorf("timed out waiting for keyspace")
		}
		entry.mutex.Lock()
	}

	if entry.value != nil {
		return entry.value, nil
	}

	return nil, entry.lastError
}
1249140
func (c *CryptoSuite) GetKey(ski []byte) (k core.Key, err error) {
	key, err := c.BCCSP.GetKey(ski)
	return GetKey(key), err
}