本文整理汇总了Golang中github.com/clawio/clawiod/config.Config类的典型用法代码示例。如果您正苦于以下问题:Golang Config类的具体用法?Golang Config怎么用?Golang Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: New
// New returns a new Service.
func New(cfg *config.Config) (services.Service, error) {
dirs := cfg.GetDirectives()
authenticator := lib.NewAuthenticator(dirs.Server.JWTSecret, dirs.Server.JWTSigningMethod)
dataController, err := data.GetDataController(cfg)
if err != nil {
return nil, err
}
authenticationController, err := authentication.GetAuthenticationController(cfg)
if err != nil {
return nil, err
}
metaDataController, err := metadata.GetMetaDataController(cfg)
if err != nil {
return nil, err
}
if err := os.MkdirAll(dirs.OCWebDAV.ChunksNamespace, 0755); err != nil {
return nil, err
}
if err := os.MkdirAll(dirs.OCWebDAV.ChunksTemporaryNamespace, 0755); err != nil {
return nil, err
}
return &svc{conf: cfg, authenticator: authenticator, dataController: dataController, metaDataController: metaDataController, authenticationController: authenticationController}, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:30,代码来源:ocwebdav.go
示例2: handleCPU
func handleCPU(cfg *config.Config) {
cpu := cfg.GetDirectives().Server.CPU
// Set CPU capacity
err := setCPU(cpu)
if err != nil {
log.Fatal("Cannot tweak CPU: ", err)
}
}
开发者ID:clawio,项目名称:clawiod,代码行数:8,代码来源:main.go
示例3: handleShowConfig
func handleShowConfig(cfg *config.Config) {
dirs := cfg.GetDirectives()
data, err := json.MarshalIndent(dirs, "", " ")
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))
os.Exit(0)
}
开发者ID:clawio,项目名称:clawiod,代码行数:9,代码来源:main.go
示例4: GetMetaDataController
// GetMetaDataController returns an already configured meta data controller.
func GetMetaDataController(conf *config.Config) (metadatacontroller.MetaDataController, error) {
dirs := conf.GetDirectives()
switch dirs.MetaData.Type {
case "simple":
return simple.New(conf)
case "ocsql":
return ocsql.New(conf)
default:
return nil, errors.New("metadata type " + dirs.MetaData.Type + "does not exist")
}
}
开发者ID:clawio,项目名称:clawiod,代码行数:12,代码来源:metadata.go
示例5: GetAuthenticationController
// GetAuthenticationController returns an already configured authentication controller.
func GetAuthenticationController(conf *config.Config) (authenticationcontroller.AuthenticationController, error) {
dirs := conf.GetDirectives()
switch dirs.Authentication.Type {
case "memory":
return memory.New(conf)
case "sql":
return sql.New(conf)
default:
return nil, errors.New("authentication type " + dirs.Authentication.Type + " does not exist")
}
}
开发者ID:clawio,项目名称:clawiod,代码行数:12,代码来源:authentication.go
示例6: New
// New returns an AuthenticationControler that
// stores users in memory. This controller is for testing purposes.
func New(conf *config.Config) (authenticationcontroller.AuthenticationController, error) {
dirs := conf.GetDirectives()
authenticator := lib.NewAuthenticator(dirs.Server.JWTSecret, dirs.Server.JWTSigningMethod)
users, err := decodeUsers(dirs.Authentication.Memory.Users)
if err != nil {
return nil, err
}
return &controller{
users: users,
authenticator: authenticator,
}, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:16,代码来源:memory.go
示例7: New
// New returns a new HTTPServer
func New(conf *config.Config) (*Server, error) {
directives := conf.GetDirectives()
srv := &graceful.Server{
NoSignalHandling: true,
Timeout: time.Duration(directives.Server.ShutdownTimeout) * time.Second,
Server: &http.Server{
Addr: fmt.Sprintf(":%d", directives.Server.Port),
},
}
s := &Server{log: helpers.GetAppLogger(conf).WithField("module", "server"), srv: srv, conf: conf}
if err := s.configureRouter(); err != nil {
return nil, err
}
return s, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:16,代码来源:server.go
示例8: New
// New returns an implementation of MetaDataController.
func New(conf *config.Config) (metadatacontroller.MetaDataController, error) {
dirs := conf.GetDirectives()
c := &controller{
namespace: dirs.MetaData.Simple.Namespace,
temporaryNamespace: dirs.MetaData.Simple.TemporaryNamespace,
}
if err := os.MkdirAll(dirs.MetaData.Simple.Namespace, 0755); err != nil {
return nil, err
}
if err := os.MkdirAll(dirs.MetaData.Simple.TemporaryNamespace, 0755); err != nil {
return nil, err
}
return c, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:18,代码来源:simple.go
示例9: getServices
func getServices(conf *config.Config) ([]services.Service, error) {
enabledServices := conf.GetDirectives().Server.EnabledServices
services := []services.Service{}
if isServiceEnabled("authentication", enabledServices) {
authenticationService, err := authentication.New(conf)
if err != nil {
return services, err
}
services = append(services, authenticationService)
}
if isServiceEnabled("metadata", enabledServices) {
metaDataService, err := metadata.New(conf)
if err != nil {
return services, err
}
services = append(services, metaDataService)
}
if isServiceEnabled("data", enabledServices) {
dataService, err := data.New(conf)
if err != nil {
return services, err
}
services = append(services, dataService)
}
if isServiceEnabled("webdav", enabledServices) {
webDAVService, err := webdav.New(conf)
if err != nil {
return services, err
}
services = append(services, webDAVService)
}
if isServiceEnabled("ocwebdav", enabledServices) {
OCWebDAVService, err := ocwebdav.New(conf)
if err != nil {
return services, err
}
services = append(services, OCWebDAVService)
}
return services, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:46,代码来源:server.go
示例10: New
// New returns an AuthenticationControler that uses a SQL database for handling
// users and JWT for tokens.
func New(conf *config.Config) (authenticationcontroller.AuthenticationController, error) {
dirs := conf.GetDirectives()
authenticator := lib.NewAuthenticator(dirs.Server.JWTSecret, dirs.Server.JWTSigningMethod)
db, err := gorm.Open(dirs.Authentication.SQL.Driver, dirs.Authentication.SQL.DSN)
if err != nil {
return nil, err
}
err = db.AutoMigrate(&userRecord{}).Error
if err != nil {
return nil, err
}
return &controller{
conf: conf,
db: db,
authenticator: authenticator,
}, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:20,代码来源:sql.go
示例11: New
// New returns an implementation of MetaDataController.
func New(conf *config.Config) (metadatacontroller.MetaDataController, error) {
dirs := conf.GetDirectives()
c := &Controller{
namespace: dirs.MetaData.OCSQL.Namespace,
temporaryNamespace: dirs.MetaData.OCSQL.TemporaryNamespace,
log: helpers.GetAppLogger(conf).WithField("module", "metadata:controller:ocsql"),
conf: conf,
}
if err := os.MkdirAll(dirs.MetaData.OCSQL.Namespace, 0755); err != nil {
return nil, err
}
if err := os.MkdirAll(dirs.MetaData.OCSQL.TemporaryNamespace, 0755); err != nil {
return nil, err
}
db, err := gorm.Open("mysql", dirs.MetaData.OCSQL.DSN)
if err != nil {
c.log.Error(err)
return nil, err
}
if dirs.MetaData.OCSQL.SQLLogEnabled {
sqlLog := helpers.NewLogger("info", dirs.MetaData.OCSQL.SQLLog,
dirs.MetaData.OCSQL.SQLLogMaxSize, dirs.MetaData.OCSQL.SQLLogMaxAge,
dirs.MetaData.OCSQL.SQLLogMaxBackups)
db.SetLogger(sqlLog)
db.LogMode(true)
}
db.DB().SetMaxIdleConns(conf.GetDirectives().MetaData.OCSQL.MaxSQLIdleConnections)
db.DB().SetMaxOpenConns(conf.GetDirectives().MetaData.OCSQL.MaxSQLConcurrentConnections)
err = db.AutoMigrate(&Record{}).Error
if err != nil {
return nil, err
}
c.db = db
return c, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:42,代码来源:ocsql.go
示例12: New
// New returns a new Service.
func New(cfg *config.Config) (services.Service, error) {
dirs := cfg.GetDirectives()
authenticator := lib.NewAuthenticator(dirs.Server.JWTSecret, dirs.Server.JWTSigningMethod)
dataController, err := data.GetDataController(cfg)
if err != nil {
return nil, err
}
authenticationController, err := authentication.GetAuthenticationController(cfg)
if err != nil {
return nil, err
}
metaDataController, err := metadata.GetMetaDataController(cfg)
if err != nil {
return nil, err
}
return &svc{conf: cfg, authenticator: authenticator, dataController: dataController, metaDataController: metaDataController, authenticationController: authenticationController}, nil
}
开发者ID:clawio,项目名称:clawiod,代码行数:22,代码来源:webdav.go
示例13: GetHTTPAccessLogger
// GetHTTPAccessLogger returns an already configured log for logging out HTTP requests.
func GetHTTPAccessLogger(conf *config.Config) *logrus.Entry {
dirs := conf.GetDirectives()
return NewLogger(dirs.Server.HTTPAccessLogLevel, dirs.Server.HTTPAccessLog,
dirs.Server.HTTPAccessLogMaxSize, dirs.Server.HTTPAccessLogMaxAge, dirs.Server.HTTPAccessLogMaxBackups)
}
开发者ID:clawio,项目名称:clawiod,代码行数:7,代码来源:helpers.go
注:本文中的github.com/clawio/clawiod/config.Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论