Git Product home page Git Product logo

cargo's Introduction

Daniel Ribeiro

"What I cannot create, I do not understand" โ€” Richard Feynman

Hey there! I'm Daniel, a self-taught programmer who likes to build things from scratch in order to understand how they work. Some topics of interest to me are network protocols, hardware emulation, compilers, game engines, graphics, decentralized technology, just to name a few.

๐ŸŒก๏ธ 549 commits in the last 24 weeks.

โšก Newest projects:

~ drgomesp.dev

cargo's People

Contributors

drgomesp avatar lukasma avatar matheusgontijo avatar vgarvardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cargo's Issues

Architectural considerations and pull-requests

When I'm looking at the code I've several questions to ask already. I know it's early stage of development, but I guess it might be good to talk about it now than later and since there are no pull-requests to master branch I thought it would be nice to ask those in here. (btw. setting master branch as protected, without merge commits and adding some TravisCI to all PRs would be nice to add)

  1. In container/builder.go method:

    // Register a new service definition
    func (b *Builder) Register(id string, fn interface{}) (builder *Builder, err error)

    is creating a definition based on fn inside and is registering this definition into the container.
    Does it really need to care about how to create definition from given interface{}?
    I was thinking that it should just receive id and definition as a parameters. Whole creation of a definition should be done somewhere else - maybe in Loader?

  2. There is method Get which will fetch service or definition. There is method GetDefinition which will fetch definition, but there is no GetService method?

  3. This file container/builder.go is about building the container itself, right? Should it be aware how to create a service basing on its definition? Wouldn't it be better to create ServiceBuilder that would have all the required logic to create service from some definition?

Proper variable namings

I can see in the code a lot of variables like fn, t, v, etc.
Wouldn't it be better to keep some naming convention with actually meaningful names for all variables?

It would be simpler to do right now, when project is young.

Add support for arguments when registering services

When registering services, it should be possible to define arguments that are going to be automatically injected once the service gets created at runtime, as the example below:

type Bar struct {}
func NewBar() *Bar {}

builder := NewBuilder()
definition := builder.Register("bar", NewBar)
definition.AddArguments(args ...interface{})

Add support for method calls when registering services

When registering services, it should be possible to define arguments that are going to be automatically injected once the service gets created at runtime, as the example below:

type Bar struct {}
func NewBar() *Bar {}
func (b *Bar) foo() {}

builder := NewBuilder()
definition := builder.Register("bar", NewBar)
definition.AddMethodCall((*Bar).foo, args ...interface{})

Support for setter injection by using service references

Example:

type MyService struct {
    DepOne SomeInterface 
    DepTwo SomeOtherInterface
}

func New() *MyService {
    return &MyService{}
}

func (s *MyService) setDepOne(depOne *SomeInterface) {
    s.DepOne = depOne
}

func (s *MyService) setDepTwo(depTwo *SomeOtherInterface) {
    s.DepTwo = depTwo
}

container.Register("my_service", New)
container.AddMethodCall("setDepOne", reference.New("dep_one_implementation"))
container.AddMethodCall("setDepTwo", reference.New("dep_two_implementation"))

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.