func NewMongoAuth(c *MongoAuthConfig) (*MongoAuth, error) { // Attempt to create new mongo session. session, err := mgo_session.New(c.MongoConfig) if err != nil { return nil, err } return &MongoAuth{ config: c, session: session, }, nil }
// NewACLMongoAuthorizer creates a new ACL Mongo authorizer func NewACLMongoAuthorizer(c *ACLMongoConfig) (Authorizer, error) { // Attempt to create new mongo session. session, err := mgo_session.New(c.MongoConfig) if err != nil { return nil, err } authorizer := &aclMongoAuthorizer{ config: c, session: session, updateTicker: time.NewTicker(c.CacheTTL), } // Initially fetch the ACL from MongoDB if err := authorizer.updateACLCache(); err != nil { return nil, err } go authorizer.continuouslyUpdateACLCache() return authorizer, nil }