英文:
Rate limited with the response MY_CONTACTS_OVERFLOW_COUNT
问题
我正在使用Google的新People API原型化一个应用程序。在我的测试中,我批量添加和删除联系人,以查看每分钟和每天可以添加多少个联系人。
我了解文档中说每分钟可以添加多少个联系人,但从我的测试结果来看,我似乎远远达不到这个限制。即使在审查我的指标时,我的请求远远超过了每分钟和每天的限制。
我主要的问题是,在我的3个Gmail帐户的服务帐户上尝试了几次之后,我现在收到了googleapi: Error 429: MY_CONTACTS_OVERFLOW_COUNT, rateLimitExceeded
的错误。我在网上找不到关于MY_CONTACTS_OVERFLOW_COUNT
的任何提及。根据错误信息,我以为是我有太多的联系人,但是当运行删除脚本时,似乎我根本没有任何联系人。
这个响应现在在我的开发机器上针对所有3个帐户返回了超过24小时,这让我相信我可能已经被阻止而不是被限制速率?
运行测试的客户端代码:
package main
import (
"context"
"log"
"google.golang.org/api/people/v1"
"os"
"bufio"
"time"
// "github.com/davecgh/go-spew/spew"
)
func chunks(xs []string, chunkSize int) [][]string {
if len(xs) == 0 {
return nil
}
divided := make([][]string, (len(xs)+chunkSize-1)/chunkSize)
prev := 0
i := 0
till := len(xs) - chunkSize
for prev < till {
next := prev + chunkSize
divided[i] = xs[prev:next]
prev = next
i++
}
divided[i] = xs[prev:]
return divided
}
func main(){
ctx := context.Background()
srv, err := people.NewService(ctx)
if err != nil {
log.Fatalf("Unable to create people Client %v", err)
}
file, err := os.Open("test125k.txt")
if err != nil {
log.Fatalf("failed opening file: %s", err)
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var txtlines []string
for scanner.Scan() {
txtlines = append(txtlines, scanner.Text())
}
chunkEmails := chunks(txtlines,200)
count := 0
var validPeopleResources []string
log.Printf("Started")
for i,chunk := range chunkEmails{ //
var contacts people.BatchCreateContactsRequest
contacts.ReadMask = "emailAddresses,photos"
for _,chunkEmail := range chunk{
var contact people.ContactToCreate
var person people.Person
var personEmails people.EmailAddress
personEmails.Value = chunkEmail
var AllEmails = [](*people.EmailAddress){
&personEmails,
}
person.EmailAddresses = AllEmails
contact.ContactPerson = &person
contacts.Contacts = append(contacts.Contacts, &contact)
}
r,err := srv.People.BatchCreateContacts(&contacts).Do()
if err != nil {
log.Printf("Unable to create contacts")
log.Printf(err.Error())
log.Fatalf("")
}
var contactEmail string
var resource string
for _, validPeople := range r.CreatedPeople {
contactEmail = validPeople.Person.EmailAddresses[0].Value
resource = validPeople.Person.ResourceName
validPeopleResources = append(validPeopleResources,resource)
}
count = count + 1
if count == 2 {
var contactToDelete people.BatchDeleteContactsRequest
contactToDelete.ResourceNames = validPeopleResources
_,err = srv.People.BatchDeleteContacts(&contactToDelete).Do()
if err != nil {
log.Printf("Unable to delete contacts")
log.Printf(err.Error())
log.Fatalf("")
}
validPeopleResources = nil
count = 0
log.Printf("performed delete")
}
log.Printf("%d comlpeted",i)
time.Sleep(10 * time.Second)
}
}
英文:
I am proto-typing an application using Google new People API. During my testing I have added and deleted contacts in batches, to see how many can be added per minute and per day in total.
I understand the documentation say how many can be added per minute, but from my testing I don't seem to get anywhere close to this. Even when reviewing my metrics, my request is far long than the supposed limits per minute and per day.
My main question I have is after a couple of attempts across a service account on 3 of my gmail account's I am now getting back googleapi: Error 429: MY_CONTACTS_OVERFLOW_COUNT, rateLimitExceeded
. I can't find any mention of MY_CONTACTS_OVERFLOW_COUNT
online. I assumed from the error it meant I have too many contacts, but when running a delete script it appears I don't have any at all.
This response is returned for all 3 accounts on my development machine now for longer than 24 hours, which is making me believe I have possibly been blocked and not rate limited?
Client code for running the test:
package main
import (
"context"
"log"
"google.golang.org/api/people/v1"
"os"
"bufio"
"time"
//"github.com/davecgh/go-spew/spew"
)
func chunks(xs []string, chunkSize int) [][]string {
if len(xs) == 0 {
return nil
}
divided := make([][]string, (len(xs)+chunkSize-1)/chunkSize)
prev := 0
i := 0
till := len(xs) - chunkSize
for prev < till {
next := prev + chunkSize
divided[i] = xs[prev:next]
prev = next
i++
}
divided[i] = xs[prev:]
return divided
}
func main(){
ctx := context.Background()
srv, err := people.NewService(ctx)
if err != nil {
log.Fatalf("Unable to create people Client %v", err)
}
file, err := os.Open("test125k.txt")
if err != nil {
log.Fatalf("failed opening file: %s", err)
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var txtlines []string
for scanner.Scan() {
txtlines = append(txtlines, scanner.Text())
}
chunkEmails := chunks(txtlines,200)
count := 0
var validPeopleResources []string
log.Printf("Started")
for i,chunk := range chunkEmails{ //
var contacts people.BatchCreateContactsRequest
contacts.ReadMask = "emailAddresses,photos"
for _,chunkEmail := range chunk{
var contact people.ContactToCreate
var person people.Person
var personEmails people.EmailAddress
personEmails.Value = chunkEmail
var AllEmails = [](*people.EmailAddress){
&personEmails,
}
person.EmailAddresses = AllEmails
contact.ContactPerson = &person
contacts.Contacts = append(contacts.Contacts, &contact)
}
r,err := srv.People.BatchCreateContacts(&contacts).Do()
if err != nil {
log.Printf("Unable to create contacts")
log.Printf(err.Error())
log.Fatalf("")
}
var contactEmail string
var resource string
for _, validPeople := range r.CreatedPeople {
contactEmail = validPeople.Person.EmailAddresses[0].Value
resource = validPeople.Person.ResourceName
validPeopleResources = append(validPeopleResources,resource)
}
count = count + 1
if count == 2 {
var contactToDelete people.BatchDeleteContactsRequest
contactToDelete.ResourceNames = validPeopleResources
_,err = srv.People.BatchDeleteContacts(&contactToDelete).Do()
if err != nil {
log.Printf("Unable to delete contacts")
log.Printf(err.Error())
log.Fatalf("")
}
validPeopleResources = nil
count = 0
log.Printf("performed delete")
}
log.Printf("%d comlpeted",i)
time.Sleep(10 * time.Second)
}
}
答案1
得分: 5
"MY_CONTACTS_OVERFLOW_COUNT"是在尝试将新联系人插入Google账户时发生的情况,但是已经达到了最大联系人数量。
自2011年以来,最大限制为25,000个联系人:https://workspaceupdates.googleblog.com/2011/05/need-more-contacts-in-gmail-contacts.html
需要注意的是,Google还会计算已删除的联系人来计算数量。你可以在联系人回收站中找到已删除的联系人。这些联系人将在30天后清除。
英文:
"MY_CONTACTS_OVERFLOW_COUNT" happens when you try to insert new contacts to the Google account, but they already have the maximum number of contacts.
The max limit is 25,000, since 2011: https://workspaceupdates.googleblog.com/2011/05/need-more-contacts-in-gmail-contacts.html
It should be noted here that Google also takes the deleted contacts into account for calculating the count. You can find the deleted contacts in the Contacts Trash. These contacts will be cleared after 30 days.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论