All Projects → vlorc → gioc

vlorc / gioc

Licence: Apache-2.0 license
golang ioc framework

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gioc

Container Ioc
Inversion of Control container & Dependency Injection for Javascript and Node.js apps powered by Typescript.
Stars: ✭ 89 (+169.7%)
Mutual labels:  ioc, factory
Python Dependency Injector
Dependency injection framework for Python
Stars: ✭ 1,203 (+3545.45%)
Mutual labels:  ioc, factory
dioc
A dart simple dependency container based on code generation.
Stars: ✭ 47 (+42.42%)
Mutual labels:  ioc
UserCenter
Personal open source user center
Stars: ✭ 28 (-15.15%)
Mutual labels:  register
dotnet-design-patterns-samples
The samples of .NET design patterns
Stars: ✭ 25 (-24.24%)
Mutual labels:  factory
di
🛠 A full-featured dependency injection container for go programming language.
Stars: ✭ 156 (+372.73%)
Mutual labels:  ioc
DependencyInjector
Lightweight dependency injector
Stars: ✭ 30 (-9.09%)
Mutual labels:  ioc
DaggerAutoInject
Inject automatically your Activities & Fragments, just with a simple annotation
Stars: ✭ 49 (+48.48%)
Mutual labels:  inject
metamorphic
A factory contract for creating metamorphic (i.e. redeployable) contracts.
Stars: ✭ 167 (+406.06%)
Mutual labels:  factory
CNeptune
CNeptune improve productivity & efficiency by urbanize .net module with meta-code to lay foundation for frameworks
Stars: ✭ 30 (-9.09%)
Mutual labels:  ioc
twitivity
🐍 Twitter Accounts Activity API Client Library for Python
Stars: ✭ 49 (+48.48%)
Mutual labels:  register
yoti-php-sdk
The PHP SDK for interacting with the Yoti Platform
Stars: ✭ 22 (-33.33%)
Mutual labels:  register
ZeroIoC
ZeroIoC is reflectionless IoC Container for .NET
Stars: ✭ 22 (-33.33%)
Mutual labels:  ioc
detection
Detection in the form of Yara, Snort and ClamAV signatures.
Stars: ✭ 70 (+112.12%)
Mutual labels:  ioc
inject
[Archived] See https://github.com/goava/di.
Stars: ✭ 49 (+48.48%)
Mutual labels:  ioc
CODE-CAMP-2020
A Virtual Hackathon Camp for Developers, Build real products and win Swags in comfort of your home.
Stars: ✭ 30 (-9.09%)
Mutual labels:  register
vue3-oop
使用类和依赖注入写vue组件
Stars: ✭ 90 (+172.73%)
Mutual labels:  ioc
tsdi
Dependency Injection container (IoC) for TypeScript
Stars: ✭ 50 (+51.52%)
Mutual labels:  ioc
hej
Hej! is a simple authentication boilerplate for Socialite.
Stars: ✭ 111 (+236.36%)
Mutual labels:  register
inject
A simple Kotlin multi-platform abstraction around the javax.inject annotations.
Stars: ✭ 42 (+27.27%)
Mutual labels:  inject

Gioc

简体中文

License codebeat badge Go Report Card GoDoc Build Status Coverage Status

gioc is a lightweight Ioc framework,it provides register and factory and depend solution

Features

  • Dependency Resolve
  • Dependency Inject
  • Singleton/Transient Support
  • Custom Tag
  • Invoker Support
  • Lazy Load
  • Struct Extends Support
  • Condition Support
  • Module Support

Installing

go get -u github.com/vlorc/gioc

Quick Start

  • Create Root Module
gioc.NewRootModule()
  • Import Module
NewModuleFactory(
    Import(
        ConfigModule,
        ServerModule,
    )
)
  • Declare Instance
NewModuleFactory(
    Declare(
        Instance(1), Id("id"),
        Instance("ioc"), Id("name"),
    ),
)
  • Export Instance
NewModuleFactory(
    Export(
        Instance(1), Id("id"),
        Instance("ioc"), Id("name"),
    ),
)
  • Condition Import
NewModuleFactory(
    Condition(
    	HavingValue(Equal("redis"), types.StringType, "cache.type"), 
    	Import(RedisModule),
    ),
    Condition(
        Or(
            Not(HavingBean(types.StringType, "cache.type")),
            HavingValue(Equal("memory"), types.StringType, "cache.type"),
        ), 
        Import(MemoryModule),
    ),
)

Examples

  • Basic Module
import (
    ."github.com/vlorc/gioc"
    ."github.com/vlorc/gioc/module"
    ."github.com/vlorc/gioc/module/operation"
)

// config.go
var ConfigModule = NewModuleFactory(
    Export(
        Mapping(map[string]interface{}{
            "id": 1,
            "name": "ioc",
        }),
    ),
)

// main.go
func main() {
    NewRootModule(
        Import(ConfigModule),
        Bootstrap(func(param struct{ id int; name string }) {
            println("id: ", param.id, " name: ",param.name)
        }),
    )
}

License

This project is under the apache License. See the LICENSE file for the full license text.

Interface

  • Provider
    • provides Factory discovery
  • Factory
    • responsible for generating Instance
    • the basic plant has a value factory, method factory, agent factory, single factory, type factory
  • Register
    • as a connection to Factory and Selector
    • provides the registration method, which eventually matches the Type to the Factory
  • Dependency
    • for target type dependency analysis, collection integration
    • converted to an Injector by an instance
  • Container
    • provides Register and Provider, and the parent container makes up traversal
    • convert to read-only Provider
    • convert to seal Container
  • Selector
    • find factory by type and name
  • Module
    • import module
    • export factory
    • declare factory

Roadmap

For details on planned features and future direction please refer to roadmap

Keyword

dependency injection, inversion of control

Reference

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].