本文整理汇总了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
}