当前位置: 首页>>代码示例>>Golang>>正文


Golang ListLogEntriesRequest.PageSize方法代码示例

本文整理汇总了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
}
开发者ID:golang,项目名称:gddo,代码行数:37,代码来源:logging_client.go

示例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
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:27,代码来源:logging_client.go


注:本文中的google/golang.org/genproto/googleapis/logging/v2.ListLogEntriesRequest.PageSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。