Example #1
0
File: main.go Project: 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
}
Example #2
0
// TODO text interface should be a service inside the service collection
func newTextInterface(newServiceCollection spec.ServiceCollection, gRPCAddr string) (spec.TextInterfaceClient, error) {
	textInterfaceConfig := text.DefaultClientConfig()
	textInterfaceConfig.GRPCAddr = gRPCAddr
	textInterfaceConfig.ServiceCollection = newServiceCollection
	newClient, err := text.NewClient(textInterfaceConfig)
	if err != nil {
		return nil, maskAny(err)
	}

	return newClient, nil
}