All Projects → insolar → component-manager

insolar / component-manager

Licence: Apache-2.0 license
component framework and dependency injection for golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to component-manager

catchflicks
🎬 Kitchen sink project for learning android concepts 🎬
Stars: ✭ 12 (-42.86%)
Mutual labels:  dependency-injection, component-architecture
mvp-architecture-kotlin-dagger-2-retrofit-android
Android Application MVP (Model-View-Presenter) architecture example using Dagger2 Dependency Injection (DI) and Retrofit Tutorial using Kotlin programming language.
Stars: ✭ 15 (-28.57%)
Mutual labels:  dependency-injection
PopKorn
DI can be simple. Forget about modules and components. Just use it!
Stars: ✭ 139 (+561.9%)
Mutual labels:  dependency-injection
vue3-oop
使用类和依赖注入写vue组件
Stars: ✭ 90 (+328.57%)
Mutual labels:  dependency-injection
definject
Unobtrusive Dependency Injector for Elixir
Stars: ✭ 46 (+119.05%)
Mutual labels:  dependency-injection
inject
[Archived] See https://github.com/goava/di.
Stars: ✭ 49 (+133.33%)
Mutual labels:  dependency-injection
android-template
Template for android development at Tiki
Stars: ✭ 17 (-19.05%)
Mutual labels:  dependency-injection
di-comparison
DI containers comparison
Stars: ✭ 20 (-4.76%)
Mutual labels:  dependency-injection
android-base-project
Android LateralView Base Project
Stars: ✭ 25 (+19.05%)
Mutual labels:  dependency-injection
AutoDI
Dependency injection made simple.
Stars: ✭ 87 (+314.29%)
Mutual labels:  dependency-injection
magnet
Dependency injection library for modular Android applications
Stars: ✭ 174 (+728.57%)
Mutual labels:  dependency-injection
di
一个简易版本的Go依赖注入实现
Stars: ✭ 133 (+533.33%)
Mutual labels:  dependency-injection
di
🛠 A full-featured dependency injection container for go programming language.
Stars: ✭ 156 (+642.86%)
Mutual labels:  dependency-injection
mindjs
Minimalistic, pure Node.js framework superpowered with Dependency Injection 💡 💻 🚀
Stars: ✭ 17 (-19.05%)
Mutual labels:  dependency-injection
tsdi
Dependency Injection container (IoC) for TypeScript
Stars: ✭ 50 (+138.1%)
Mutual labels:  dependency-injection
dodrugs
A macro-powered dependency injector for Haxe
Stars: ✭ 29 (+38.1%)
Mutual labels:  dependency-injection
toolkit
some useful library of the php
Stars: ✭ 15 (-28.57%)
Mutual labels:  dependency-injection
noicejs
extremely thin async dependency injection
Stars: ✭ 16 (-23.81%)
Mutual labels:  dependency-injection
fast-blazor
Blazor component library for FluentUI. Microsoft's official lightweight wrapper around the FluentUI Web Components for use with .NET 6.0 Blazor applications
Stars: ✭ 928 (+4319.05%)
Mutual labels:  component-architecture
unbox
Fast, simple, easy-to-use DI container
Stars: ✭ 45 (+114.29%)
Mutual labels:  dependency-injection

Overview

Component Manager provides dependency injection and lifecycle management for component-based monolith architecture apps.

See Demo application

Build Status GolangCI Go Report Card GoDoc codecov

Features

  • two step initialization
  • reflect based dependency injection for interfaces
  • resolving circular dependency
  • components lifecycle support
  • ordered start, gracefully stop with reverse order
  • easy component and integration tests with mock
  • subcomponents support
  • reduce boilerplate code

Contetns

Basic usage

Installing

To start using Component Manager, install Go 1.9 or above and run go get:

$ go get github.com/insolar/component-manager

Component definition

A Component is a struct which can have dependencies and/or can implement lifecycle interfaces.

Dependencies defined as fields in the struct and must be an interface type. have to be exportable because reflect can set only exportable struct fields. Also Dependencies must have tag inject:"".

    type Supermarket struct {
        Warehouse core.Warehouse `inject:""`
    }

	cm := component.NewManager(nil)
	cm.Register(producer.NewFarm(), producer.NewDoorFactory())
	cm.Register(&supermarket.Supermarket{}, &warehouse.Warehouse{})
	cm.Register(NewCustomer("Bob"), NewCustomer("Alice"))
	cm.Inject()

Component lifecycle

Usually components lives from app process executes till process finished.

  • new(instance created, first initialization)
  • inject(required dependency injected)
  • init(second initialization)
  • start(component can call their dependency interfaces, run goroutines)
  • prepare stop(optional)
  • stop (gracefully stop goroutines, close descriptors)

Component constructor

Constructor with config as param.

Init and start

When should use Init and when Start? What does it means.

Stop and gracefully stop

tbd

intefaces

type Initer interface {
	Init(ctx context.Context) error
}

type Starter interface {
	Start(ctx context.Context) error
}

type GracefulStopper interface {
	GracefulStop(ctx context.Context) error
}

type Stopper interface {
	Stop(ctx context.Context) error
}

Similar projects

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].