當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Config.GetDirectives方法代碼示例

本文整理匯總了Golang中github.com/clawio/clawiod/config.Config.GetDirectives方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.GetDirectives方法的具體用法?Golang Config.GetDirectives怎麽用?Golang Config.GetDirectives使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/clawio/clawiod/config.Config的用法示例。


在下文中一共展示了Config.GetDirectives方法的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.GetDirectives方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。