Giter Club home page Giter Club logo

goremy-di's Introduction

Remy

A package that helps the creation of golang dependency injections.

About

The main job of a dependency-injection package is to help providing objects, instances, closures to a caller, by avoiding a depth graph in parameter pass. Knowing this, and using culinary as inspiration, we thought that a DI (dependency injection) package is like a Sous chef in a cuisine, so we take decided to reference the best Sous chef we know: " Remy"!

Inspiration

This package is heavily inspired by the flutter module Modular Dependency Injection

Instance registration

The strategy for building an instance with its dependencies comprise on registering all objects in a module and instantiate them on demand or in single-instance form(singleton). This 'registration' is called Bind.

There are a few ways to build a Bind to register object instances:

  • Bind.singleton: Build an instance only once at the bind registration.
  • Bind.lazySingleton: Build an instance only once when element is retrieved at first time.
  • Bind.factory: Build an instance on demand.
  • Bind.instance: Adds an existing instance as it is.

Other information about binds, functions and injectors can be found easily at spec

goremy-di's People

Contributors

forcetower avatar jictyvoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

forcetower

goremy-di's Issues

injector: Add two operation modes while registering injections

Add a Injector config to set two distinct modes, RegisterAppendMode, RegisterSingleMode

  • RegisterSingleMode, as it currently works, only register one and then panic (default)
  • RegisterAppendMode, will start to register every element normally, but after the second injection with same key, it will be saved on cache as an array
    • For elements that has more than one registered element, Get will panic

Mostly in implementation changes, it most affect only storage and cacheType config

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.