本文整理汇总了Golang中github.com/xh3b4sd/anna/service/id.MustNewID函数的典型用法代码示例。如果您正苦于以下问题:Golang MustNewID函数的具体用法?Golang MustNewID怎么用?Golang MustNewID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MustNewID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}