Exemplo n.º 1
0
// DefaultConfig provides a default configuration to create a new server object
// by best effort.
func DefaultConfig() Config {
	newInstrumentation, err := memory.NewInstrumentation(memory.DefaultInstrumentationConfig())
	if err != nil {
		panic(err)
	}

	newLogControl, err := logcontrol.NewControl(logcontrol.DefaultControlConfig())
	if err != nil {
		panic(err)
	}

	newTextInterface, err := text.NewServer(text.DefaultServerConfig())
	if err != nil {
		panic(err)
	}

	newConfig := Config{
		// Dependencies.

		Instrumentation: newInstrumentation,
		Log:             log.New(log.DefaultConfig()),
		LogControl:      newLogControl,
		TextInterface:   newTextInterface,

		// Settings.

		GRPCAddr: "127.0.0.1:9119",
		HTTPAddr: "127.0.0.1:9120",
	}

	return newConfig
}
Exemplo n.º 2
0
Arquivo: main.go Projeto: xh3b4sd/anna
// 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
}
Exemplo n.º 3
0
// DefaultStorageConfig provides a default configuration to create a new memory
// storage object by best effort.
func DefaultStorageConfig() StorageConfig {
	newConfig := StorageConfig{
		// Dependencies.
		Log: log.New(log.DefaultConfig()),
	}

	return newConfig
}
Exemplo n.º 4
0
// DefaultServerConfig provides a default configuration to create a new text
// interface object by best effort.
func DefaultServerConfig() ServerConfig {
	newConfig := ServerConfig{
		Log:               log.New(log.DefaultConfig()),
		ServiceCollection: service.MustNewCollection(),
	}

	return newConfig
}
Exemplo n.º 5
0
// DefaultConfig provides a default configuration to create a new CLG object by
// best effort.
func DefaultConfig() Config {
	newConfig := Config{
		// Dependencies.
		ServiceCollection: service.MustNewCollection(),
		Log:               log.New(log.DefaultConfig()),
		StorageCollection: storage.MustNewCollection(),
	}

	return newConfig
}
Exemplo n.º 6
0
// DefaultConfig provides a default configuration to create a new CLG
// collection object by best effort.
func DefaultConfig() Config {
	newIDService, err := id.New(id.DefaultConfig())
	if err != nil {
		panic(err)
	}

	newConfig := Config{
		// Dependencies.
		IDService: newIDService,
		Log:       log.New(log.DefaultConfig()),
	}

	return newConfig
}
Exemplo n.º 7
0
// DefaultConfig provides a default configuration to create a new network
// object by best effort.
func DefaultConfig() Config {
	newConfig := Config{
		// Dependencies.
		Activator:         activator.MustNew(),
		ServiceCollection: service.MustNewCollection(),
		Forwarder:         forwarder.MustNew(),
		Log:               log.New(log.DefaultConfig()),
		StorageCollection: storage.MustNewCollection(),
		Tracker:           tracker.MustNew(),

		// Settings.
		Delay: 0,
	}

	return newConfig
}
Exemplo n.º 8
0
// DefaultStorageConfig provides a default configuration to create a new redis
// storage object by best effort.
func DefaultStorageConfig() StorageConfig {
	newInstrumentation, err := memory.NewInstrumentation(memory.DefaultInstrumentationConfig())
	if err != nil {
		panic(err)
	}

	newStorageConfig := StorageConfig{
		// Dependencies.
		Instrumentation: newInstrumentation,
		Log:             log.New(log.DefaultConfig()),
		Pool:            NewPool(DefaultPoolConfig()),

		// Settings.
		BackoffFactory: func() spec.Backoff {
			return &backoff.StopBackOff{}
		},
		Prefix: "prefix",
	}

	return newStorageConfig
}
Exemplo n.º 9
0
func Test_RedisStorage_retryErrorLogger(t *testing.T) {
	newRootLogger := testMustNewRootLogger(t)

	newLogConfig := log.DefaultConfig()
	newLogConfig.RootLogger = newRootLogger
	newLog := log.New(newLogConfig)

	newConfig := DefaultStorageConfig()
	newConfig.Log = newLog
	newStorage, err := NewStorage(newConfig)
	if err != nil {
		t.Fatal("expected", nil, "got", err)
	}

	newStorage.(*storage).retryErrorLogger(invalidConfigError, 0)
	result := newRootLogger.(*rootLogger).ArgsToString()

	if !strings.Contains(result, invalidConfigError.Error()) {
		t.Fatal("expected", invalidConfigError.Error(), "got", result)
	}
}
Exemplo n.º 10
0
Arquivo: main.go Projeto: xh3b4sd/anna
// DefaultConfig provides a default configuration to create a new annad object
// by best effort.
func DefaultConfig() Config {
	newServer, err := server.New(server.DefaultConfig())
	if err != nil {
		panic(err)
	}

	newConfig := Config{
		// Dependencies.
		Log:               log.New(log.DefaultConfig()),
		Network:           network.MustNew(),
		Server:            newServer,
		ServiceCollection: service.MustNewCollection(),
		// TODO remove storage collection
		StorageCollection: storage.MustNewCollection(),

		// Settings.
		Flags:   Flags{},
		Version: version,
	}

	return newConfig
}
Exemplo n.º 11
0
// DefaultControlConfig provides a default configuration to create a new log control
// object by best effort.
func DefaultControlConfig() ControlConfig {
	return ControlConfig{
		// Dependencies.
		Log: log.New(log.DefaultConfig()),
	}
}