// GAT performs a get-and-touch request on the remote backend
965888
func (h Handler) GAT(cmd common.GATRequest) (common.GetResponse, error) {
	if err := binprot.WriteGATCmd(h.rw.Writer, cmd.Key, cmd.Exptime, 0); err != nil {
		return common.GetResponse{}, err
	}

	data, flags, _, err := getLocal(h.rw, false)
	if err != nil {
		if err == common.ErrKeyNotFound {
			return common.GetResponse{
				Miss:   true,
				Quiet:  false,
				Opaque: cmd.Opaque,
				Flags:  flags,
				Key:    cmd.Key,
				Data:   nil,
			}, nil
		}

		return common.GetResponse{}, err
	}

	return common.GetResponse{
		Miss:   false,
		Quiet:  false,
		Opaque: cmd.Opaque,
		Flags:  flags,
		Key:    cmd.Key,
		Data:   data,
	}, nil
}
1171529
func (s *HostService) GetHostTagID(keyword string, opts ...OptionFunc) (string, int, error) {
	p := &ListHostTagsParams{}
	p.p = make(map[string]interface{})

	p.p["keyword"] = keyword

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListHostTags(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
	}

	if l.Count == 1 {
		return l.HostTags[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.HostTags {
			if v.Name == keyword {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
}
305170
func GetT(t testing.T, n int) (ports []int) {
	ports, err := Free(n)
	if err != nil {
		t.Fatalf("Failed retrieving free port: %v", err)
	}

	return ports
}
179124
func (c *Client) GAT(key string, exp uint32) (val string, flags uint32, cas uint64, err error) {
	// Variants: GAT [Q, K, KQ]
	// Request : MUST key, extras; MUST NOT value
	// Response: MAY key, value, extras ([0..3] flags)
	m := &msg{
		header: header{
			Op: opGAT,
		},
		iextras: []interface{}{exp},
		oextras: []interface{}{&flags},
		key:     key,
	}

	err = c.perform(m)
	return m.val, flags, m.CAS, err
}
1328602
func (q Queue) TouchMessage(msgId string) (err error) {
	return q.queues(q.Name, "messages", msgId, "touch").Req("POST", nil, nil)
}
771774
func (m *nativeGitClient) goGitFetch() error {
	repo, err := git.PlainOpen(m.root)
	if err != nil {
		return err
	}

	log.Debug("git fetch origin --tags --force")
	err = repo.Fetch(&git.FetchOptions{
		RemoteName: git.DefaultRemoteName,
		Auth:       m.auth,
		Tags:       git.AllTags,
		Force:      true,
	})
	if err == git.NoErrAlreadyUpToDate {
		return nil
	}
	return err
}
1023393
func (batch *MessageBatch) Touch() {
	atomic.StoreInt64(batch.lastFlush, time.Now().Unix())
}
533933
func (v *Plugin_Handshake_Args) GetRequest() (o *HandshakeRequest) {
	if v != nil && v.Request != nil {
		return v.Request
	}

	return
}
1225515
func (g *GistFork) GetUpdatedAt() Timestamp {
	if g == nil || g.UpdatedAt == nil {
		return Timestamp{}
	}
	return *g.UpdatedAt
}
467580
func Init(services *disco.Disco) {
	backendsLock.Lock()
	defer backendsLock.Unlock()

	backends = map[string]backend.InitFn{
		// Enhanced backends.
		"local":  func() backend.Backend { return backendLocal.New() },
		"remote": func() backend.Backend { return backendRemote.New(services) },

		// Remote State backends.
		"artifactory": func() backend.Backend { return backendArtifactory.New() },
		"atlas":       func() backend.Backend { return backendAtlas.New() },
		"azurerm":     func() backend.Backend { return backendAzure.New() },
		"consul":      func() backend.Backend { return backendConsul.New() },
		"etcd":        func() backend.Backend { return backendEtcdv2.New() },
		"etcdv3":      func() backend.Backend { return backendEtcdv3.New() },
		"gcs":         func() backend.Backend { return backendGCS.New() },
		"http":        func() backend.Backend { return backendHTTP.New() },
		"inmem":       func() backend.Backend { return backendInmem.New() },
		"manta":       func() backend.Backend { return backendManta.New() },
		"pg":          func() backend.Backend { return backendPg.New() },
		"s3":          func() backend.Backend { return backendS3.New() },
		"swift":       func() backend.Backend { return backendSwift.New() },

		// Deprecated backends.
		"azure": func() backend.Backend {
			return deprecateBackend(
				backendAzure.New(),
				`Warning: "azure" name is deprecated, please use "azurerm"`,
			)
		},
	}
}
951673
func (f ApiAppHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, app *models.App) {
	f(w, r, app)
}
1065984
func (c *GetAppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	name, ok := mux.Vars(r)[appNamePath]
	if !ok {
		http.Error(w, jsonErrStr("missing app name in path"), http.StatusBadRequest)
		return
	}
	app := &models.App{}
	err := c.db.Get(models.NewAppKey(name), app)
	if err == db.ErrNotFound {
		http.Error(w, jsonErrStr(fmt.Sprintf("app %s not found", name)), http.StatusNotFound)
		return
	} else if err != nil {
		http.Error(w, jsonErrStr(fmt.Sprintf("database error: %s", err)), http.StatusInternalServerError)
		return
	}
	if err := json.NewEncoder(w).Encode(app); err != nil {
		http.Error(w, jsonErr(err, "encoding json"), http.StatusInternalServerError)
		return
	}
}
1230586
func (table requestCostTable) getCost(code, amount uint64) uint64 {
	costs := table[code]
	return costs.baseCost + amount*costs.reqCost
}
628970
func (b *Filter) Touch(d []byte) bool {
	n := len(b.items)
	h := hash(b.key0, b.key1, d)
	i := h % uint64(n)
	return b.touch(&b.items[i])
}
816210
func (h *handle) cgoGet(cgoid int) (cg cgoif, found bool) {
	if cgoid == 0 {
		return nil, false
	}

	h.cgoLock.Lock()
	defer h.cgoLock.Unlock()
	cg, found = h.cgomap[cgoid]
	if found {
		delete(h.cgomap, cgoid)
	}

	return cg, found
}
299533
func (b *Bucket) Touch(key string, cas Cas, expiry uint32) (Cas, error) {
	cas, _, err := b.touch(key, cas, expiry)
	return cas, err
}
332021
func getRequest(d logrus.Fields, key string) (req *http.Request, ok bool) {
	v, ok := d[key]
	if !ok {
		return nil, false
	}
	req, ok = v.(*http.Request)
	if !ok || req == nil {
		return nil, false
	}
	return req, true
}