core

package module
Version: v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 16 Imported by: 7

README

Procyon Core

Go Report Card codecov Build Status Gitter PkgGoDev

This gives you a basic understanding of Procyon Core Module.

Components

All instances managed by the framework such as Controller, Initializers and Processors are considered as a component.

Register Component

It's used to register the components. However, you can pass only a construction-function into it. Construction function means a function returning only one type but it can have multiple parameters.

func Register(components ...Component)

The example is given below.

type MyComponent struct {

}

func NewMyComponent() MyComponent {
    return MyComponent{}
}

func init() {
    core.Register(NewMyComponent) 
}
Component Processor

This allows you to process the components registered before application starts.

type ComponentProcessor interface {
	SupportsComponent(typ goo.Type) bool
	ProcessComponent(typ goo.Type) error
}
  • SupportsComponent if it returns true, it means that the component will be processed by this component processor.
  • ProcessComponent If the method SupportComponent returns true, it will be invoked.

The example of a custom component processor is given below.

type CustomComponentProcessor struct {
}

func NewCustomComponentProcessor() CustomComponentProcessor {
	return CustomComponentProcessor{}
}

func (processor CustomComponentProcessor) SupportsComponent(typ goo.Type) bool {
	// do whatever you want
    return false
}

func (processor CustomComponentProcessor) ProcessComponent(typ goo.Type) error {
	// do whatever you want
    return nil
}

Note that you need to register the component processors by using the function core.Register.

License

Procyon Framework is released under version 2.0 of the Apache License

Documentation

Index

Constants

View Source
const NonOptionArgsPropertyName = "nonOptionArgs"
View Source
const ProcyonAppFilePath = "test-resources/"
View Source
const ProcyonAppFilePrefix = "procyon"
View Source
const ProcyonAppFilePropertySource = "ProcyonAppFilePropertySource"
View Source
const ProcyonAppFileSuffix = ".yaml"
View Source
const ProcyonApplicationCommandLinePropertySource = "ProcyonApplicationCommandLinePropertySource"
View Source
const ProcyonDefaultProfile = "default"
View Source
const ProcyonSystemEnvironmentPropertySource = "ProcyonSystemEnvironmentPropertySource"

Variables

This section is empty.

Functions

func BytesToStr

func BytesToStr(bytes []byte) string

func FlatMap

func FlatMap(m map[string]interface{}) map[string]interface{}

func ForEachComponentProcessor

func ForEachComponentProcessor(callback func(string, goo.Type) error) (err error)

func ForEachComponentType

func ForEachComponentType(callback func(string, goo.Type) error) (err error)

func GenerateUUID

func GenerateUUID(uuidBuffer []byte)

func GetComponentTypes

func GetComponentTypes(requestedType goo.Type) ([]goo.Type, error)

func GetComponentTypesWithParam

func GetComponentTypesWithParam(requestedType goo.Type, paramTypes []goo.Type) ([]goo.Type, error)

func Register

func Register(components ...Component)

Types

type AppFileParser

type AppFileParser struct {
}

func NewAppFileParser

func NewAppFileParser() *AppFileParser

func (*AppFileParser) Parse

func (parser *AppFileParser) Parse(filePaths []string) (map[string]interface{}, error)

type AppFilePropertySource

type AppFilePropertySource struct {
	// contains filtered or unexported fields
}

func NewAppFilePropertySource

func NewAppFilePropertySource(profiles string) *AppFilePropertySource

func (*AppFilePropertySource) ContainsProperty

func (propertySource *AppFilePropertySource) ContainsProperty(name string) bool

func (*AppFilePropertySource) GetName

func (propertySource *AppFilePropertySource) GetName() string

func (*AppFilePropertySource) GetProperty

func (propertySource *AppFilePropertySource) GetProperty(name string) interface{}

func (*AppFilePropertySource) GetPropertyNames

func (propertySource *AppFilePropertySource) GetPropertyNames() []string

func (*AppFilePropertySource) GetSource

func (propertySource *AppFilePropertySource) GetSource() interface{}

type BooleanToStringConverter

type BooleanToStringConverter struct {
}

func NewBooleanToStringConverter

func NewBooleanToStringConverter() BooleanToStringConverter

func (BooleanToStringConverter) Convert

func (converter BooleanToStringConverter) Convert(source interface{}, sourceTyp goo.Type, targetTyp goo.Type) (interface{}, error)

func (BooleanToStringConverter) Support

func (converter BooleanToStringConverter) Support(sourceTyp goo.Type, targetTyp goo.Type) bool

type CommandLineArgs

type CommandLineArgs struct {
	// contains filtered or unexported fields
}

func NewCommandLineArgs

func NewCommandLineArgs() CommandLineArgs

type CommandLinePropertySource

type CommandLinePropertySource interface {
	PropertySource
	ContainsOption(name string) bool
	GetOptionValues(name string) []string
	GetNonOptionArgs() []string
}

type Component

type Component interface{}

type ComponentProcessor

type ComponentProcessor interface {
	SupportsComponent(typ goo.Type) bool
	ProcessComponent(typ goo.Type) error
}

type ConfigurableEnvironment

type ConfigurableEnvironment interface {
	Environment
	GetPropertySources() *PropertySources
	GetSystemEnvironment() []string
	GetTypeConverterService() TypeConverterService
}

type DefaultTypeConverterService

type DefaultTypeConverterService struct {
	// contains filtered or unexported fields
}

func NewDefaultTypeConverterService

func NewDefaultTypeConverterService() *DefaultTypeConverterService

func (*DefaultTypeConverterService) CanConvert

func (cs *DefaultTypeConverterService) CanConvert(sourceTyp goo.Type, targetTyp goo.Type) bool

func (*DefaultTypeConverterService) Convert

func (cs *DefaultTypeConverterService) Convert(source interface{}, sourceTyp goo.Type, targetTyp goo.Type) (result interface{}, err error)

func (*DefaultTypeConverterService) RegisterConverter

func (cs *DefaultTypeConverterService) RegisterConverter(converter TypeConverter)

type Environment

type Environment interface {
	PropertyResolver
}

type NumberToStringConverter

type NumberToStringConverter struct {
}

func NewNumberToStringConverter

func NewNumberToStringConverter() NumberToStringConverter

func (NumberToStringConverter) Convert

func (converter NumberToStringConverter) Convert(source interface{}, sourceTyp goo.Type, targetTyp goo.Type) (interface{}, error)

func (NumberToStringConverter) Support

func (converter NumberToStringConverter) Support(sourceTyp goo.Type, targetTyp goo.Type) bool

type Priority

type Priority interface {
	GetPriority() PriorityValue
}

type PriorityValue

type PriorityValue int32
const PriorityHighest PriorityValue = math.MinInt32
const PriorityLowest PriorityValue = math.MaxInt32

type PropertyResolver

type PropertyResolver interface {
	ContainsProperty(name string) bool
	GetProperty(name string, defaultValue string) interface{}
}

type PropertySource

type PropertySource interface {
	GetName() string
	GetSource() interface{}
	GetProperty(name string) interface{}
	ContainsProperty(name string) bool
	GetPropertyNames() []string
}

type PropertySources

type PropertySources struct {
	// contains filtered or unexported fields
}

func NewPropertySources

func NewPropertySources() *PropertySources

func (*PropertySources) Add

func (o *PropertySources) Add(propertySource PropertySource)

func (*PropertySources) Get

func (o *PropertySources) Get(name string) (PropertySource, bool)

func (*PropertySources) GetPropertyResources

func (o *PropertySources) GetPropertyResources() []PropertySource

func (*PropertySources) GetSize

func (o *PropertySources) GetSize() int

func (*PropertySources) Remove

func (o *PropertySources) Remove(name string) PropertySource

func (*PropertySources) RemoveIfPresent

func (o *PropertySources) RemoveIfPresent(propertySource PropertySource)

func (*PropertySources) Replace

func (o *PropertySources) Replace(name string, propertySource PropertySource)

type SimpleCommandLineArgsParser

type SimpleCommandLineArgsParser struct {
}

func NewCommandLineArgsParser

func NewCommandLineArgsParser() SimpleCommandLineArgsParser

func (SimpleCommandLineArgsParser) Parse

func (parser SimpleCommandLineArgsParser) Parse(args []string) (CommandLineArgs, error)

type SimpleCommandLinePropertySource

type SimpleCommandLinePropertySource struct {
	// contains filtered or unexported fields
}

func NewSimpleCommandLinePropertySource

func NewSimpleCommandLinePropertySource(args []string) SimpleCommandLinePropertySource

func (SimpleCommandLinePropertySource) ContainsOption

func (cmdLineSource SimpleCommandLinePropertySource) ContainsOption(name string) bool

func (SimpleCommandLinePropertySource) ContainsProperty

func (cmdLineSource SimpleCommandLinePropertySource) ContainsProperty(name string) bool

func (SimpleCommandLinePropertySource) GetName

func (cmdLineSource SimpleCommandLinePropertySource) GetName() string

func (SimpleCommandLinePropertySource) GetNonOptionArgs

func (cmdLineSource SimpleCommandLinePropertySource) GetNonOptionArgs() []string

func (SimpleCommandLinePropertySource) GetOptionValues

func (cmdLineSource SimpleCommandLinePropertySource) GetOptionValues(name string) []string

func (SimpleCommandLinePropertySource) GetProperty

func (cmdLineSource SimpleCommandLinePropertySource) GetProperty(name string) interface{}

func (SimpleCommandLinePropertySource) GetPropertyNames

func (cmdLineSource SimpleCommandLinePropertySource) GetPropertyNames() []string

func (SimpleCommandLinePropertySource) GetSource

func (cmdLineSource SimpleCommandLinePropertySource) GetSource() interface{}

type SimplePropertyResolver

type SimplePropertyResolver struct {
	// contains filtered or unexported fields
}

func NewSimplePropertyResolver

func NewSimplePropertyResolver(sources *PropertySources) *SimplePropertyResolver

func (*SimplePropertyResolver) ContainsProperty

func (resolver *SimplePropertyResolver) ContainsProperty(name string) bool

func (*SimplePropertyResolver) GetProperty

func (resolver *SimplePropertyResolver) GetProperty(name string, defaultValue string) interface{}

type StandardEnvironment

type StandardEnvironment struct {
	// contains filtered or unexported fields
}

func NewStandardEnvironment

func NewStandardEnvironment() StandardEnvironment

func (StandardEnvironment) ContainsProperty

func (env StandardEnvironment) ContainsProperty(name string) bool

func (StandardEnvironment) GetProperty

func (env StandardEnvironment) GetProperty(name string, defaultValue string) interface{}

func (StandardEnvironment) GetPropertySources

func (env StandardEnvironment) GetPropertySources() *PropertySources

func (StandardEnvironment) GetSystemEnvironment

func (env StandardEnvironment) GetSystemEnvironment() []string

func (StandardEnvironment) GetTypeConverterService

func (env StandardEnvironment) GetTypeConverterService() TypeConverterService

type StringToBooleanConverter

type StringToBooleanConverter struct {
}

func NewStringToBooleanConverter

func NewStringToBooleanConverter() StringToBooleanConverter

func (StringToBooleanConverter) Convert

func (converter StringToBooleanConverter) Convert(source interface{}, sourceTyp goo.Type, targetTyp goo.Type) (result interface{}, err error)

func (StringToBooleanConverter) Support

func (converter StringToBooleanConverter) Support(sourceTyp goo.Type, targetTyp goo.Type) bool

type StringToNumberConverter

type StringToNumberConverter struct {
}

func NewStringToNumberConverter

func NewStringToNumberConverter() StringToNumberConverter

func (StringToNumberConverter) Convert

func (converter StringToNumberConverter) Convert(source interface{}, sourceTyp goo.Type, targetTyp goo.Type) (interface{}, error)

func (StringToNumberConverter) Support

func (converter StringToNumberConverter) Support(sourceTyp goo.Type, targetTyp goo.Type) bool

type SystemEnvironmentPropertySource

type SystemEnvironmentPropertySource struct {
	// contains filtered or unexported fields
}

func NewSystemEnvironmentPropertySource

func NewSystemEnvironmentPropertySource() SystemEnvironmentPropertySource

func (SystemEnvironmentPropertySource) ContainsProperty

func (propertySource SystemEnvironmentPropertySource) ContainsProperty(name string) bool

func (SystemEnvironmentPropertySource) GetName

func (propertySource SystemEnvironmentPropertySource) GetName() string

func (SystemEnvironmentPropertySource) GetProperty

func (propertySource SystemEnvironmentPropertySource) GetProperty(name string) interface{}

func (SystemEnvironmentPropertySource) GetPropertyNames

func (propertySource SystemEnvironmentPropertySource) GetPropertyNames() []string

func (SystemEnvironmentPropertySource) GetSource

func (propertySource SystemEnvironmentPropertySource) GetSource() interface{}

type TaskWatch

type TaskWatch struct {
	// contains filtered or unexported fields
}

func NewTaskWatch

func NewTaskWatch() *TaskWatch

func NewTaskWatchWithName

func NewTaskWatchWithName(taskName string) *TaskWatch

func (*TaskWatch) GetTotalTime

func (watch *TaskWatch) GetTotalTime() int64

func (*TaskWatch) IsRunning

func (watch *TaskWatch) IsRunning() bool

func (*TaskWatch) Start

func (watch *TaskWatch) Start() error

func (*TaskWatch) Stop

func (watch *TaskWatch) Stop() error

type TypeConverter

type TypeConverter interface {
	Support(sourceTyp goo.Type, targetTyp goo.Type) bool
	Convert(source interface{}, sourceTyp goo.Type, targetTyp goo.Type) (interface{}, error)
}

type TypeConverterRegistry

type TypeConverterRegistry interface {
	RegisterConverter(converter TypeConverter)
}

type TypeConverterService

type TypeConverterService interface {
	TypeConverterRegistry
	CanConvert(sourceTyp goo.Type, targetTyp goo.Type) bool
	Convert(source interface{}, sourceTyp goo.Type, targetTyp goo.Type) (interface{}, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL