Esempio n. 1
0
// NewConfigClient creates a new config service client.
//
// Service for configuring sinks used to export log entries outside Stackdriver
// Logging.
func NewConfigClient(ctx context.Context, opts ...option.ClientOption) (*ConfigClient, error) {
	conn, err := transport.DialGRPC(ctx, append(defaultConfigClientOptions(), opts...)...)
	if err != nil {
		return nil, err
	}
	c := &ConfigClient{
		conn:        conn,
		client:      loggingpb.NewConfigServiceV2Client(conn),
		CallOptions: defaultConfigCallOptions(),
	}
	c.SetGoogleClientInfo("gax", gax.Version)
	return c, nil
}
Esempio n. 2
0
func (it *SinkIterator) fetch(pageSize int, pageToken string) (string, error) {
	// TODO(jba): Do this a nicer way if the generated code supports one.
	// TODO(jba): If the above TODO can't be done, find a way to pass metadata in the call.
	client := logpb.NewConfigServiceV2Client(it.client.Connection())
	var res *logpb.ListSinksResponse
	err := gax.Invoke(it.ctx, func(ctx context.Context) error {
		it.req.PageSize = trunc32(pageSize)
		it.req.PageToken = pageToken
		var err error
		res, err = client.ListSinks(ctx, it.req)
		return err
	}, it.client.CallOptions.ListSinks...)
	if err != nil {
		return "", err
	}
	for _, sp := range res.Sinks {
		it.items = append(it.items, fromLogSink(sp))
	}
	return res.NextPageToken, nil
}