本文整理匯總了Golang中google/golang.org/genproto/googleapis/logging/v2.ListLogEntriesRequest.PageSize方法的典型用法代碼示例。如果您正苦於以下問題:Golang ListLogEntriesRequest.PageSize方法的具體用法?Golang ListLogEntriesRequest.PageSize怎麽用?Golang ListLogEntriesRequest.PageSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google/golang.org/genproto/googleapis/logging/v2.ListLogEntriesRequest
的用法示例。
在下文中一共展示了ListLogEntriesRequest.PageSize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ListLogEntries
// ListLogEntries lists log entries. Use this method to retrieve log entries from Cloud
// Logging. For ways to export log entries, see
// [Exporting Logs](/logging/docs/export).
func (c *Client) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest) *LogEntryIterator {
md, _ := metadata.FromContext(ctx)
ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata))
it := &LogEntryIterator{}
fetch := func(pageSize int, pageToken string) (string, error) {
var resp *loggingpb.ListLogEntriesResponse
req.PageToken = pageToken
if pageSize > math.MaxInt32 {
req.PageSize = math.MaxInt32
} else {
req.PageSize = int32(pageSize)
}
err := gax.Invoke(ctx, func(ctx context.Context) error {
var err error
resp, err = c.client.ListLogEntries(ctx, req)
return err
}, c.CallOptions.ListLogEntries...)
if err != nil {
return "", err
}
it.items = append(it.items, resp.Entries...)
return resp.NextPageToken, nil
}
bufLen := func() int { return len(it.items) }
takeBuf := func() interface{} {
b := it.items
it.items = nil
return b
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, bufLen, takeBuf)
return it
}
示例2: ListLogEntries
// ListLogEntries lists log entries. Use this method to retrieve log entries from Cloud
// Logging. For ways to export log entries, see
// [Exporting Logs](/logging/docs/export).
func (c *Client) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest) *LogEntryIterator {
ctx = metadata.NewContext(ctx, c.metadata)
it := &LogEntryIterator{}
it.apiCall = func() error {
var resp *loggingpb.ListLogEntriesResponse
err := gax.Invoke(ctx, func(ctx context.Context) error {
var err error
req.PageToken = it.nextPageToken
req.PageSize = it.pageSize
resp, err = c.client.ListLogEntries(ctx, req)
return err
}, c.CallOptions.ListLogEntries...)
if err != nil {
return err
}
if resp.NextPageToken == "" {
it.atLastPage = true
}
it.nextPageToken = resp.NextPageToken
it.items = resp.Entries
return nil
}
return it
}