本文整理汇总了Golang中github.com/xh3b4sd/anna/service/id.MustNewID函数的典型用法代码示例。如果您正苦于以下问题:Golang MustNewID函数的具体用法?Golang MustNewID怎么用?Golang MustNewID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MustNewID函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewStorage
// NewStorage creates a new configured redis storage object.
func NewStorage(config StorageConfig) (spec.Storage, error) {
newStorage := &storage{
StorageConfig: config,
ID: id.MustNewID(),
ShutdownOnce: sync.Once{},
Type: ObjectType,
}
// Dependencies.
if newStorage.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newStorage.Pool == nil {
return nil, maskAnyf(invalidConfigError, "connection pool must not be empty")
}
// Settings.
if newStorage.BackoffFactory == nil {
return nil, maskAnyf(invalidConfigError, "backoff factory must not be empty")
}
if newStorage.Prefix == "" {
return nil, maskAnyf(invalidConfigError, "prefix must not be empty")
}
newStorage.Log.Register(newStorage.GetType())
return newStorage, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:29,代码来源:storage.go
示例2: New
// New creates a new configured feature set object. A feature set tries to
// detect all patterns within the configured input sequences.
func New(config Config) (spec.FeatureSet, error) {
newFeatureSet := &featureSet{
Config: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Type: ObjectTypeFeatureSet,
}
if newFeatureSet.MaxLength < -1 {
return nil, maskAnyf(invalidConfigError, "MaxLength must be greater than -2")
}
if newFeatureSet.MinLength < 1 {
return nil, maskAnyf(invalidConfigError, "MaxLength must be greater than 0")
}
if newFeatureSet.MaxLength != -1 && newFeatureSet.MaxLength < newFeatureSet.MinLength {
return nil, maskAnyf(invalidConfigError, "MaxLength must be equal to or greater thanMinLength")
}
if newFeatureSet.MinCount < 0 {
return nil, maskAnyf(invalidConfigError, "MinCount must be greater than -1")
}
if len(newFeatureSet.Sequences) == 0 {
return nil, maskAnyf(invalidConfigError, "sequences must not be empty")
}
return newFeatureSet, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:28,代码来源:feature_set.go
示例3: New
// New creates a new configured annad object.
func New(config Config) (spec.Annad, error) {
newAnna := &annad{
Config: config,
BootOnce: sync.Once{},
ID: id.MustNewID(),
ShutdownOnce: sync.Once{},
Type: ObjectType,
}
if newAnna.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newAnna.Network == nil {
return nil, maskAnyf(invalidConfigError, "network must not be empty")
}
if newAnna.Server == nil {
return nil, maskAnyf(invalidConfigError, "server must not be empty")
}
if newAnna.ServiceCollection == nil {
return nil, maskAnyf(invalidConfigError, "service collection must not be empty")
}
if newAnna.StorageCollection == nil {
return nil, maskAnyf(invalidConfigError, "storage collection must not be empty")
}
return newAnna, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:29,代码来源:main.go
示例4: New
// New creates a new configured forwarder object.
func New(config Config) (systemspec.Forwarder, error) {
newForwarder := &forwarder{
Config: config,
ID: id.MustNewID(),
Type: ObjectType,
}
// Dependencies.
if newForwarder.ServiceCollection == nil {
return nil, maskAnyf(invalidConfigError, "factory collection must not be empty")
}
if newForwarder.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newForwarder.StorageCollection == nil {
return nil, maskAnyf(invalidConfigError, "storage collection must not be empty")
}
// Settings.
if newForwarder.MaxSignals == 0 {
return nil, maskAnyf(invalidConfigError, "maximum signals must not be empty")
}
newForwarder.Log.Register(newForwarder.GetType())
return newForwarder, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:29,代码来源:forwarder.go
示例5: New
// New creates a new configured network object.
func New(config Config) (systemspec.Network, error) {
newNetwork := &network{
Config: config,
BootOnce: sync.Once{},
Closer: make(chan struct{}, 1),
ID: id.MustNewID(),
ShutdownOnce: sync.Once{},
Type: ObjectType,
}
if newNetwork.Activator == nil {
return nil, maskAnyf(invalidConfigError, "activator must not be empty")
}
if newNetwork.Forwarder == nil {
return nil, maskAnyf(invalidConfigError, "forwarder must not be empty")
}
if newNetwork.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newNetwork.ServiceCollection == nil {
return nil, maskAnyf(invalidConfigError, "service collection must not be empty")
}
if newNetwork.StorageCollection == nil {
return nil, maskAnyf(invalidConfigError, "storage collection must not be empty")
}
if newNetwork.Tracker == nil {
return nil, maskAnyf(invalidConfigError, "tracker must not be empty")
}
newNetwork.CLGs = newNetwork.newCLGs()
newNetwork.Log.Register(newNetwork.GetType())
return newNetwork, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:36,代码来源:network.go
示例6: NewDistribution
// NewDistribution creates a new configured distribution object. A distribution
// represents a weighted analysis of vectors. A two dimensional distribution
// can be seen as bar chart.
//
// ^
// | x
// | x
// | x x
// y | x x
// | x x
// | x x x
// | x x x x
// | x x x x
// +------------------------>
// x
//
func NewDistribution(config Config) (spec.Distribution, error) {
newDistribution := &distribution{
Config: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Type: ObjectTypeDistribution,
}
if newDistribution.Name == "" {
return nil, maskAnyf(invalidConfigError, "name must not be empty")
}
if len(newDistribution.Vectors) == 0 {
return nil, maskAnyf(invalidConfigError, "vectors must not be empty")
}
if !equalDimensionLength(newDistribution.Vectors) {
return nil, maskAnyf(invalidConfigError, "vectors must have equal dimensions")
}
if len(newDistribution.StaticChannels) == 0 {
return nil, maskAnyf(invalidConfigError, "vectors must not be empty")
}
if !uniqueFloat64(newDistribution.StaticChannels) {
return nil, maskAnyf(invalidConfigError, "static channels must be unique")
}
sort.Float64s(newDistribution.StaticChannels)
return newDistribution, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:44,代码来源:distribution.go
示例7: NewFeature
// NewFeature creates a new configured feature object. A feature represents a
// differentiable part of a given sequence.
func NewFeature(config FeatureConfig) (spec.Feature, error) {
newFeature := &feature{
Distribution: nil,
FeatureConfig: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Type: ObjectTypeFeature,
}
if len(newFeature.Positions) == 0 {
return nil, maskAnyf(invalidConfigError, "positions must not be empty")
}
if newFeature.Sequence == "" {
return nil, maskAnyf(invalidConfigError, "sequence must not be empty")
}
newConfig := distribution.DefaultConfig()
newConfig.Name = newFeature.Sequence
newConfig.Vectors = newFeature.Positions
newDistribution, err := distribution.NewDistribution(newConfig)
if err != nil {
return nil, maskAnyf(invalidConfigError, err.Error())
}
newFeature.Distribution = newDistribution
return newFeature, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:29,代码来源:feature.go
示例8: DefaultConfig
// DefaultConfig provides a default configuration to create a new command line
// object by best effort.
func DefaultConfig() Config {
newLogControl, err := logcontrol.NewControl(logcontrol.DefaultControlConfig())
if err != nil {
panic(err)
}
newTextInterface, err := text.NewClient(text.DefaultClientConfig())
if err != nil {
panic(err)
}
newConfig := Config{
// Dependencies.
Log: log.New(log.DefaultConfig()),
LogControl: newLogControl,
ServiceCollection: service.MustNewCollection(),
TextInterface: newTextInterface,
// Settings.
Flags: Flags{},
SessionID: string(id.MustNewID()),
Version: version,
}
return newConfig
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:28,代码来源:main.go
示例9: New
// New creates a new configured network payload object.
func New(config Config) (spec.NetworkPayload, error) {
newObject := &networkPayload{
Config: config,
ID: id.MustNewID(),
}
return newObject, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:10,代码来源:networkpayload.go
示例10: NewFileSystem
// NewFileSystem creates a new configured real OS file system.
func NewFileSystem(config Config) servicespec.FS {
newFileSystem := &osFileSystem{
Config: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Type: ObjectType,
}
newFileSystem.Log.Register(newFileSystem.GetType())
return newFileSystem
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:13,代码来源:os.go
示例11: New
// New creates a new configured context object.
func New(config Config) (spec.Context, error) {
newContext := &context{
Config: config,
ID: string(id.MustNewID()),
}
if newContext.Context == nil {
return nil, maskAnyf(invalidConfigError, "context must not be empty")
}
return newContext, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:14,代码来源:context.go
示例12: New
// New creates a new configured CLG collection object.
func New(config Config) (systemspec.CLGCollection, error) {
newCollection := &collection{
Config: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Type: ObjectTypeCLGCollection,
}
newCollection.Log.Register(newCollection.GetType())
return newCollection, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:14,代码来源:collection.go
示例13: New
// New creates a new configured log object.
func New(config Config) spec.Log {
newLog := log{
Config: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
RegisteredObjects: []spec.ObjectType{},
Type: ObjectType,
}
newLog.Register(newLog.GetType())
return &newLog
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:15,代码来源:log.go
示例14: New
// New creates a new configured memory file system.
func New(config Config) (servicespec.FS, error) {
newService := &service{
Config: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Storage: map[string][]byte{},
Type: ObjectType,
}
if newService.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
return newService, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:16,代码来源:mem.go
示例15: NewControl
// NewControl creates a new configured log control object.
func NewControl(config ControlConfig) (spec.LogControl, error) {
newControl := &control{
ControlConfig: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Type: ObjectType,
}
if newControl.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
newControl.Log.Register(newControl.GetType())
return newControl, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:17,代码来源:control.go
示例16: New
// New creates a new configured server object.
func New(config Config) (spec.Server, error) {
newServer := &server{
Config: config,
BootOnce: sync.Once{},
Closer: make(chan struct{}, 1),
GRPCServer: grpc.NewServer(),
HTTPServer: &graceful.Server{
NoSignalHandling: true,
Server: &http.Server{
Addr: config.HTTPAddr,
},
Timeout: 3 * time.Second,
},
ID: id.MustNewID(),
Mutex: sync.Mutex{},
ShutdownOnce: sync.Once{},
Type: spec.ObjectType(ObjectTypeServer),
}
// Dependencies.
if newServer.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newServer.LogControl == nil {
return nil, maskAnyf(invalidConfigError, "log control must not be empty")
}
if newServer.TextInterface == nil {
return nil, maskAnyf(invalidConfigError, "text interface must not be empty")
}
// Settings.
if newServer.GRPCAddr == "" {
return nil, maskAnyf(invalidConfigError, "gRPC address must not be empty")
}
if newServer.HTTPAddr == "" {
return nil, maskAnyf(invalidConfigError, "HTTP address must not be empty")
}
newServer.Log.Register(newServer.GetType())
return newServer, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:46,代码来源:server.go
示例17: NewServer
// NewServer creates a new configured text interface object.
func NewServer(config ServerConfig) (TextInterfaceServer, error) {
newServer := &server{
ServerConfig: config,
ID: id.MustNewID(),
Mutex: sync.Mutex{},
Type: ObjectType,
}
if newServer.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newServer.ServiceCollection == nil {
return nil, maskAnyf(invalidConfigError, "service collection must not be empty")
}
newServer.Log.Register(newServer.GetType())
return newServer, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:21,代码来源:server.go
示例18: New
// New creates a new configured activator object.
func New(config Config) (systemspec.Activator, error) {
newActivator := &activator{
Config: config,
ID: id.MustNewID(),
Type: ObjectType,
}
if newActivator.ServiceCollection == nil {
return nil, maskAnyf(invalidConfigError, "factory collection must not be empty")
}
if newActivator.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newActivator.StorageCollection == nil {
return nil, maskAnyf(invalidConfigError, "storage collection must not be empty")
}
newActivator.Log.Register(newActivator.GetType())
return newActivator, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:23,代码来源:activator.go
示例19: New
// New creates a new configured CLG object.
func New(config Config) (spec.CLG, error) {
newCLG := &clg{
Config: config,
ID: id.MustNewID(),
Name: "islesser",
Type: ObjectType,
}
// Dependencies.
if newCLG.ServiceCollection == nil {
return nil, maskAnyf(invalidConfigError, "factory collection must not be empty")
}
if newCLG.Log == nil {
return nil, maskAnyf(invalidConfigError, "logger must not be empty")
}
if newCLG.StorageCollection == nil {
return nil, maskAnyf(invalidConfigError, "storage collection must not be empty")
}
newCLG.Log.Register(newCLG.GetType())
return newCLG, nil
}
开发者ID:xh3b4sd,项目名称:anna,代码行数:24,代码来源:generated_calculate.go
注:本文中的github.com/xh3b4sd/anna/service/id.MustNewID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论