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


Golang cloud.WithContext函数代码示例

本文整理汇总了Golang中google/golang.org/cloud.WithContext函数的典型用法代码示例。如果您正苦于以下问题:Golang WithContext函数的具体用法?Golang WithContext怎么用?Golang WithContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WithContext函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: pubsubContext

func pubsubContext(ctx context.Context, projectID string) (context.Context, error) {
	httpClient, err := google.DefaultClient(ctx, pubsub.ScopePubSub)
	if err != nil {
		return nil, err
	}
	return cloud.WithContext(ctx, projectID, httpClient), nil
}
开发者ID:wuman,项目名称:golang-samples,代码行数:7,代码来源:pubsub.go

示例2: newPubSubService

func newPubSubService(ctx context.Context, config pubsubConfig, client *http.Client) (pubSubService, error) {
	if config.project == "" {
		return nil, errors.New("pubsub: you must supply a project")
	}
	return &pubSubServiceImpl{
		ctx: cloud.WithContext(ctx, config.project, client),
	}, nil
}
开发者ID:nicko96,项目名称:Chrome-Infra,代码行数:8,代码来源:pubsub.go

示例3: cloudContext

func cloudContext(projectID string) (context.Context, error) {
	ctx := context.Background()
	httpClient, err := google.DefaultClient(ctx, storage.ScopeFullControl, pubsub.ScopePubSub)
	if err != nil {
		return nil, err
	}
	return cloud.WithContext(ctx, projectID, httpClient), nil
}
开发者ID:huxq17,项目名称:golang-samples,代码行数:8,代码来源:config.go

示例4: handleFunc

func handleFunc(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	c.Infof("env: %v", os.Environ())
	client, err := serviceaccount.NewClient(c, "https://www.googleapis.com/auth/devstorage.read_write")
	c.Infof("client=%+v err=%+v", client, err)
	cc := cloud.WithContext(context.Background(), appengine.AppID(c), client)
	bucket, err := storage.BucketInfo(cc, appengine.AppID(c)+".appspot.com")
	c.Infof("bucket=%+v err=%+v", bucket, err)
}
开发者ID:christopherhesse,项目名称:disgusting-appengine-context-hack,代码行数:9,代码来源:testgcs.go

示例5: Context

// Context returns an cloud.Context based on the receiver Config.
func (c *Config) Context(ctx context.Context) (context.Context, error) {
	if c.ProjectID == "" {
		return nil, errors.New("oauth2 configuration missing project ID")
	}
	cl, err := c.Client(ctx)
	if err != nil {
		return nil, err
	}
	return cloud.WithContext(ctx, c.ProjectID, cl), nil
}
开发者ID:jwatt,项目名称:kythe,代码行数:11,代码来源:oauth2.go

示例6: Generate

func (cfg *AppengineStoreConfig) Generate(c context.Context) files.FileStore {
	hc := &http.Client{
		Transport: &oauth2.Transport{
			Source: google.AppEngineTokenSource(c, storage.ScopeFullControl),
			Base:   &urlfetch.Transport{Context: c},
		},
	}
	ctx := cloud.WithContext(c, appengine.AppID(c), hc)
	return &AppengineStore{cfg, ctx}
}
开发者ID:orian,项目名称:files,代码行数:10,代码来源:appengine.go

示例7: cloudAuthContext

// Get an auth context for logging RPC.
func cloudAuthContext(r *http.Request) (context.Context, error) {
	c := appengine.NewContext(r)

	hc := &http.Client{
		Transport: &oauth2.Transport{
			Source: google.AppEngineTokenSource(c, logging.Scope),
			Base:   &urlfetch.Transport{Context: c},
		},
	}
	return cloud.WithContext(c, appengine.AppID(c), hc), nil
}
开发者ID:tomayac,项目名称:amphtml,代码行数:12,代码来源:errortracker.go

示例8: cloudAuthContext

func cloudAuthContext(r *http.Request) (context.Context, error) {
	c := appengine.NewContext(r)

	hc := &http.Client{
		Transport: &oauth2.Transport{
			Source: google.AppEngineTokenSource(c, storage.ScopeFullControl),
			Base:   &urlfetch.Transport{Context: c},
		},
	}
	return cloud.WithContext(c, "rule110-go", hc), nil

}
开发者ID:matthewdu,项目名称:rule110-go,代码行数:12,代码来源:googlecloudstorage.go

示例9: context

func (d *driver) context(context ctx.Context) context.Context {
	return cloud.WithContext(context, dummyProjectID, d.client)
}
开发者ID:tv42,项目名称:pachyderm,代码行数:3,代码来源:gcs.go

示例10: CloudContext

func CloudContext(parent context.Context) context.Context {
	if parent == nil {
		return cloud.NewContext(projID, cloudClient)
	}
	return cloud.WithContext(parent, projID, cloudClient)
}
开发者ID:flowlo,项目名称:coduno-api,代码行数:6,代码来源:cloud.go

示例11: context

func (this *SalesforceOpportunityEvents) context(ctx context.Context) context.Context {
	return cloud.WithContext(ctx, this.projectID, this.conf.Client(oauth2.NoContext))
}
开发者ID:RobotsAndPencils,项目名称:slack-salesforce-bot,代码行数:3,代码来源:sf_opportunity_events.go


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