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