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


Golang State.NewBakeryStorage方法代码示例

本文整理汇总了Golang中github.com/juju/juju/state.State.NewBakeryStorage方法的典型用法代码示例。如果您正苦于以下问题:Golang State.NewBakeryStorage方法的具体用法?Golang State.NewBakeryStorage怎么用?Golang State.NewBakeryStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/juju/juju/state.State的用法示例。


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

示例1: newAuthContext

// newAuthContext creates a new authentication context for st.
func newAuthContext(st *state.State) (*authContext, error) {
	ctxt := &authContext{
		st: st,
		// TODO(fwereade) 2016-07-21 there should be a clock parameter
		clock: clock.WallClock,
		localUserInteractions: authentication.NewInteractions(),
	}

	// Create a bakery service for discharging third-party caveats for
	// local user authentication. This service does not persist keys;
	// its macaroons should be very short-lived.
	localUserThirdPartyBakeryService, _, err := newBakeryService(st, nil, nil)
	if err != nil {
		return nil, errors.Trace(err)
	}
	ctxt.localUserThirdPartyBakeryService = localUserThirdPartyBakeryService

	// Create a bakery service for local user authentication. This service
	// persists keys into MongoDB in a TTL collection.
	store, err := st.NewBakeryStorage()
	if err != nil {
		return nil, errors.Trace(err)
	}
	locator := bakeryServicePublicKeyLocator{ctxt.localUserThirdPartyBakeryService}
	localUserBakeryService, localUserBakeryServiceKey, err := newBakeryService(
		st, store, locator,
	)
	if err != nil {
		return nil, errors.Trace(err)
	}
	ctxt.localUserBakeryService = &expirableStorageBakeryService{
		localUserBakeryService, localUserBakeryServiceKey, store, locator,
	}
	return ctxt, nil
}
开发者ID:bac,项目名称:juju,代码行数:36,代码来源:authcontext.go

示例2: newAuthContext

// newAuthContext creates a new authentication context for st.
func newAuthContext(st *state.State) (*authContext, error) {
	ctxt := &authContext{st: st}
	store, err := st.NewBakeryStorage()
	if err != nil {
		return nil, errors.Trace(err)
	}
	// We use a non-nil, but empty key, because we don't use the
	// key, and don't want to incur the overhead of generating one
	// each time we create a service.
	bakeryService, key, err := newBakeryService(st, store, nil)
	if err != nil {
		return nil, errors.Trace(err)
	}
	ctxt.userAuth.Service = &expirableStorageBakeryService{bakeryService, key, store, nil}
	// TODO(fwereade): 2016-03-17 lp:1558657
	ctxt.userAuth.Clock = state.GetClock()
	return ctxt, nil
}
开发者ID:makyo,项目名称:juju,代码行数:19,代码来源:authcontext.go


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