Skip to content

procyon-projects/procyon-core

Repository files navigation

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

About

It provides essential infrastructures and utilities for Procyon Framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages