src/server/pps/server/api_server.go
func (a *apiServer) incrementGCGeneration(ctx context.Context) error {
	resp, err := a.env.GetEtcdClient().Get(ctx, client.GCGenerationKey)
	if err != nil {
		return err
	}

	if resp.Count == 0 {
		// If the generation number does not exist, create it.
		// It's important that the new generation is 1, as the first
		// generation is assumed to be 0.
		if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, "1"); err != nil {
			return err
		}
	} else {
		oldGen, err := strconv.Atoi(string(resp.Kvs[0].Value))
		if err != nil {
			return err
		}
		newGen := oldGen + 1
		if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, strconv.Itoa(newGen)); err != nil {
			return err
		}
	}
	return nil
}
func (a *apiServer) incrementGCGeneration(ctx context.Context) error {
	resp, err := a.env.GetEtcdClient().Get(ctx, client.GCGenerationKey)
	if err != nil {
		return err
	}

	if resp.Count == 0 {
		// If the generation number does not exist, create it.
		// It's important that the new generation is 1, as the first
		// generation is assumed to be 0.
		if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, "1"); err != nil {
			return err
		}
	} else {
		oldGen, err := strconv.Atoi(string(resp.Kvs[0].Value))
		if err != nil {
			return err
		}
		newGen := oldGen + 1
		if _, err := a.env.GetEtcdClient().Put(ctx, client.GCGenerationKey, strconv.Itoa(newGen)); err != nil {
			return err
		}
	}
	return nil
}
func ( a * apiServer ) incrementGCGeneration ( ctx context . Context ) error { resp , err := a . env . GetEtcdClient ( ) . Get ( ctx , client . GCGenerationKey ) if err != nil { return err } if resp . Count == 0 { // If the generation number does not exist, create it. // It's important that the new generation is 1, as the first // generation is assumed to be 0. if _ , err := a . env . GetEtcdClient ( ) . Put ( ctx , client . GCGenerationKey , " " ) ; err != nil { return err } } else { oldGen , err := strconv . Atoi ( string ( resp . Kvs [ 0 ] . Value ) ) if err != nil { return err } newGen := oldGen + 1 if _ , err := a . env . GetEtcdClient ( ) . Put ( ctx , client . GCGenerationKey , strconv . Itoa ( newGen ) ) ; err != nil { return err } } return nil }
// incrementGCGeneration increments the GC generation number in etcd
incrementGCGeneration increments the GC generation number in etcd