freedom

package module
Version: v1.8.11 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

Freedom DDD Framework

License Go Report Card Build Status GoDoc GitHub release

Freedom是一个基于六边形架构的框架,可以支撑充血的领域模型范式。

Overview

  • 集成 Iris
  • HTTP/H2C Server & Client
  • 集成普罗米修斯
  • AOP Worker & 无侵入 Context
  • 可扩展组件 Infrastructure
  • 依赖注入 & 依赖倒置 & 开闭原则
  • DDD & 六边形架构
  • 领域事件 & 消息队列组件
  • CQS & 聚合根
  • CRUD & PO Generate
  • 一级缓存 & 二级缓存 & 防击穿

安装

$ go get github.com/8treenet/freedom/freedom

脚手架创建项目

$ freedom new-project [project-name]

脚手架生成增删查改和持久化对象

# freedom new-po -h 查看更多
$ cd [project-name]

# 数据库数据源方式
$ freedom new-po --dsn "root:123123@tcp(127.0.0.1:3306)/freedom?charset=utf8"

# JSON 数据源方式
$ freedom new-po --json ./domain/po/schema.json

Example

基础教程
http2监听和依赖倒置
事务组件&自定义组件&Kafka&领域事件组件
一个完整的电商demo,包含CQS、聚合、实体、领域事件、资源库、基础设施

Documentation

Index

Constants

View Source
const (
	//TransactionKey for transaction DB handles in the first-level cache
	TransactionKey = internal.TransactionKey
)

Variables

View Source
var (

	// EnvProfileDir is the name of the environment variable for the search
	// directory of the profile
	EnvProfileDir = "FREEDOM_PROJECT_CONFIG"

	// ProfileENV is the name of the profile directory in environment variable
	ProfileENV = EnvProfileDir
)

Functions

func Configure added in v0.0.3

func Configure(obj interface{}, file string, metaData ...interface{}) error

Configure .

func DefaultConfiguration added in v1.6.9

func DefaultConfiguration() iris.Configuration

DefaultConfiguration Proxy a call to iris.DefaultConfiguration

func IsDir added in v1.8.8

func IsDir(dir string) bool

IsDir accepts a string with a directory path and tests the path. It returns true if the path exists and it is a directory, and false otherwise.

func IsFile added in v1.8.8

func IsFile(path string) bool

IsFile accepts a string with a file path and tests the path. It returns true if the path exists and it is a file, and false otherwise.

func JoinPath added in v1.8.8

func JoinPath(elems ...string) string

JoinPath returns a string that joins any number of path elements into a single path, separating them with slashes.

func Logger

func Logger() *golog.Logger

Logger Return to global logger.

func Prepare added in v1.6.2

func Prepare(f func(Initiator))

Prepare A prepared function is passed in for initialization.

func ProfileDirFromEnv added in v1.8.8

func ProfileDirFromEnv() string

ProfileDirFromEnv reads from environment variable with EnvProfileDir

func Prometheus added in v1.5.5

func Prometheus() *internal.Prometheus

Prometheus Return prometheus.

func ReadProfile added in v1.8.8

func ReadProfile(file string, v interface{}) error

ReadProfile accepts a string with the name of a profile file, and search the file by detectProfilePath. It will fill v with the configuration by parsing the profile into toml format, and returns nil if the file has found. It returns error, if the file has not been found or any error encountered.

func ServiceLocator added in v1.8.8

func ServiceLocator() *internal.ServiceLocatorImpl

ServiceLocator Return serviceLocator. Use the service locator to get the service.

func SetConfigurator added in v1.8.8

func SetConfigurator(c Configurator)

SetConfigurator assigns a Configurator to global configurator

func SetConfigurer added in v1.6.9

func SetConfigurer(c Configurer)

SetConfigurer assigns a Configurator to global configurator

Types

type Application

type Application interface {
	// Install the database. A function that returns the Interface type is passed in as a handle to the database.
	InstallDB(f func() (db interface{}))
	// Install the redis. A function that returns the redis.Cmdable is passed in as a handle to the client.
	InstallRedis(f func() (client redis.Cmdable))
	// Install a custom data source. A function that returns the Interface type is passed in as a handle to the custom data sources.
	InstallCustom(f func() interface{})
	// Install the middleware for http routing globally.
	InstallMiddleware(handler iris.Handler)
	// Assigns specified prefix to the application-level router.
	// Because of ambiguous naming, I've been create SetPrefixPath as an alternative.
	// Considering remove this function in the future.
	InstallParty(relativePath string)
	// NewRunner Can be used as an argument for the `Run` method.
	NewRunner(addr string, configurators ...host.Configurator) iris.Runner
	// NewH2CRunner Create a Runner for H2C .
	NewH2CRunner(addr string, configurators ...host.Configurator) iris.Runner
	// NewAutoTLSRunner Can be used as an argument for the `Run` method.
	NewAutoTLSRunner(addr string, domain string, email string, configurators ...host.Configurator) iris.Runner
	// NewTLSRunner Can be used as an argument for the `Run` method.
	NewTLSRunner(addr string, certFile, keyFile string, configurators ...host.Configurator) iris.Runner
	// Go back to the iris app.
	Iris() *iris.Application
	// Return to global logger.
	Logger() *golog.Logger
	// Run serving an iris application as the HTTP server to handle the incoming requests
	Run(serve iris.Runner, c iris.Configuration)
	// Adds a builder function which builds a BootManager.
	BindBooting(f func(bootManager BootManager))
	// Install the middleware for the message bus.
	InstallBusMiddleware(handle ...BusHandler)
	InstallSerializer(marshal func(v interface{}) ([]byte, error), unmarshal func(data []byte, v interface{}) error)
}

Application Represents an application of freedom

func NewApplication added in v1.0.5

func NewApplication() Application

NewApplication Create an application.

type BeforeActivation added in v1.7.1

type BeforeActivation = IrisBeforeActivation

BeforeActivation is Is the start-up pre-processing of the action.

type BootManager added in v1.8.9

type BootManager = internal.BootManager

BootManager Can be used to launch in the application.

type Bus added in v1.6.2

type Bus = internal.Bus

Bus Message bus, using http header to pass through data.

type BusHandler added in v1.6.2

type BusHandler = internal.BusHandler

BusHandler is the bus message middleware type.

type Configuration added in v1.6.9

type Configuration = IrisConfiguration

Configuration is the configuration type of the app.

type Configurator added in v1.8.8

type Configurator interface {
	Configure(obj interface{}, file string, metaData ...interface{}) error
}

Configurator .

type Configurer added in v1.6.9

type Configurer = Configurator

Configurer .

type Context added in v1.3.0

type Context = IrisContext

Context is the context type.

type DomainEvent added in v1.8.6

type DomainEvent = internal.DomainEvent

DomainEvent Interface definition of domain events for subscription and publishing of entities.

type Entity added in v1.3.7

type Entity = internal.Entity

Entity is the entity's father interface.

type Infra added in v1.3.0

type Infra = internal.Infra

Infra The parent class of the infrastructure, which can be inherited using the parent class's methods.

type Initiator

type Initiator = internal.Initiator

Initiator Initialize the binding relationship between the user's code and the associated code.

type IrisBeforeActivation added in v1.8.8

type IrisBeforeActivation = mvc.BeforeActivation

IrisBeforeActivation represents an type alias to mvc.BeforeActivation

type IrisConfiguration added in v1.8.8

type IrisConfiguration = iris.Configuration

IrisConfiguration represents an type alias to iris.Configuration

type IrisContext added in v1.8.8

type IrisContext = iris.Context

IrisContext represents an type alias to iris.Context

type IrisResult added in v1.8.8

type IrisResult = hero.Result

IrisResult represents an type alias to hero.Result

type LogFields added in v1.7.16

type LogFields = golog.Fields

LogFields is the column type of the log.

type LogRow added in v1.7.16

type LogRow = golog.Log

LogRow is the log per line callback.

type Repository

type Repository = internal.Repository

Repository The parent class of the repository, which can be inherited using the parent class's methods.

type Result added in v1.3.0

type Result = IrisResult

Result is the controller return type.

type UnitTest added in v1.4.0

type UnitTest = internal.UnitTest

UnitTest is a unit test tool.

func NewUnitTest added in v1.4.0

func NewUnitTest() UnitTest

NewUnitTest Unit testing tools.

type Worker added in v1.7.1

type Worker = internal.Worker

Worker Request a runtime object.

func ToWorker added in v1.7.1

func ToWorker(ctx Context) Worker

ToWorker proxy a call to WorkerFromCtx.

func WorkerFromCtx added in v1.8.8

func WorkerFromCtx(ctx Context) Worker

WorkerFromCtx extracts Worker from a Context.

Directories

Path Synopsis
example
base/adapter/repository
Package repository code generated by 'freedom new-project base' Package repository code generated by 'freedom new-project base'
Package repository code generated by 'freedom new-project base' Package repository code generated by 'freedom new-project base'
base/domain
Package domain generated by 'freedom new-project base'
Package domain generated by 'freedom new-project base'
base/domain/po
Package po generated by 'freedom new-project base'
Package po generated by 'freedom new-project base'
base/domain/vo
Package vo generated by 'freedom new-project base'
Package vo generated by 'freedom new-project base'
base/infra
Package infra generated by 'freedom new-project base' Package infra generated by 'freedom new-project base'
Package infra generated by 'freedom new-project base' Package infra generated by 'freedom new-project base'
base/server
Package main code generated by 'freedom new-project base'
Package main code generated by 'freedom new-project base'
fshop/domain/po
Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po'
Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po' Package po generated by 'freedom new-po'
fshop/infra
Package infra code generated by 'freedom new-project base' Package infra code generated by 'freedom new-project base'
Package infra code generated by 'freedom new-project base' Package infra code generated by 'freedom new-project base'
fshop/server
Code generated by 'freedom new-project fshop'
Code generated by 'freedom new-project fshop'
infra-example/domain/po
Package po generated by 'freedom new-po' Package po generated by 'freedom new-po'
Package po generated by 'freedom new-po' Package po generated by 'freedom new-po'
infra-example/domain/vo
Package vo code generated by 'freedom new-project infra-example'
Package vo code generated by 'freedom new-project infra-example'
infra-example/infra
Package infra code generated by 'freedom new-project base' Package infra code generated by 'freedom new-project base'
Package infra code generated by 'freedom new-project base' Package infra code generated by 'freedom new-project base'
infra-example/server
Code generated by 'freedom new-project infra-example'
Code generated by 'freedom new-project infra-example'
cmd
infra

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