import "go.chromium.org/luci/gae/filter/count"
Package count contains 'counter' filters for all the gae services. This serves as a set of simple example filters, and also enables other filters to test to see if certain underlying APIs are called when they should be (e.g. for the datastore mcache filter, for example).
count.go gi.go mail.go mc.go mod.go rds.go tq.go user.go
type DSCounter struct { AllocateIDs Entry DecodeCursor Entry RunInTransaction Entry Run Entry Count Entry DeleteMulti Entry GetMulti Entry PutMulti Entry }
DSCounter is the counter object for the datastore service.
FilterRDS installs a counter datastore filter in the context.
Code:
// Set up your context using a base service implementation (memory or prod) c := memory.Use(context.Background()) // Apply the counter.FilterRDS c, counter := FilterRDS(c) // functions use ds from the context like normal... they don't need to know // that there are any filters at all. someCalledFunc := func(c context.Context) { vals := []ds.PropertyMap{{ "FieldName": ds.MkProperty(100), "$key": ds.MkProperty(ds.NewKey(c, "Kind", "", 1, nil))}, } if err := ds.Put(c, vals); err != nil { panic(err) } } // Using the other function. someCalledFunc(c) someCalledFunc(c) // Then we can see what happened! fmt.Printf("%d\n", counter.PutMulti.Successes())
Output:
2
type Entry struct {
// contains filtered or unexported fields
}
Entry is a success/fail pair for a single API method. It's returned by the Counter interface.
Errors returns the number of unsuccessful invocations for this Entry.
Successes returns the number of successful invocations for this Entry.
Total is a convenience function for getting the total number of calls to this API. It's Successes+Errors.
type InfoCounter struct { AppID Entry FullyQualifiedAppID Entry GetNamespace Entry Datacenter Entry DefaultVersionHostname Entry InstanceID Entry IsDevAppServer Entry IsOverQuota Entry IsTimeoutError Entry ModuleHostname Entry ModuleName Entry RequestID Entry ServerSoftware Entry ServiceAccount Entry VersionID Entry Namespace Entry AccessToken Entry PublicCertificates Entry SignBytes Entry }
InfoCounter is the counter object for the GlobalInfo service.
FilterGI installs a counter GlobalInfo filter in the context.
type MCCounter struct { NewItem Entry AddMulti Entry SetMulti Entry GetMulti Entry DeleteMulti Entry CompareAndSwapMulti Entry Increment Entry Flush Entry Stats Entry }
MCCounter is the counter object for the Memcache service.
FilterMC installs a counter Memcache filter in the context.
MailCounter is the counter object for the Mail service.
FilterMail installs a counter Mail filter in the context.
type ModuleCounter struct { List Entry NumInstances Entry SetNumInstances Entry Versions Entry DefaultVersion Entry Start Entry Stop Entry }
ModuleCounter is the counter object for the Module service.
FilterModule installs a counter Module filter in the context.
type TQCounter struct { AddMulti Entry DeleteMulti Entry Lease Entry LeaseByTag Entry ModifyLease Entry Purge Entry Stats Entry }
TQCounter is the counter object for the TaskQueue service.
FilterTQ installs a counter TaskQueue filter in the context.
type UserCounter struct { Current Entry CurrentOAuth Entry IsAdmin Entry LoginURL Entry LoginURLFederated Entry LogoutURL Entry OAuthConsumerKey Entry }
UserCounter is the counter object for the User service.
FilterUser installs a counter User filter in the context.
Package count imports 11 packages (graph). Updated 2021-01-23. Refresh now. Tools for package owners.