{"id":30056982,"url":"https://github.com/insolar/component-manager","last_synced_at":"2025-08-07T23:32:44.410Z","repository":{"id":129608403,"uuid":"158745752","full_name":"insolar/component-manager","owner":"insolar","description":"component framework and dependency injection for golang","archived":false,"fork":false,"pushed_at":"2019-10-28T20:40:06.000Z","size":32,"stargazers_count":22,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-19T01:50:57.528Z","etag":null,"topics":["component-architecture","dependency-injection","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/insolar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-22T20:06:36.000Z","updated_at":"2023-06-08T15:23:59.000Z","dependencies_parsed_at":"2023-03-22T14:47:47.388Z","dependency_job_id":null,"html_url":"https://github.com/insolar/component-manager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/insolar/component-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insolar%2Fcomponent-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insolar%2Fcomponent-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insolar%2Fcomponent-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insolar%2Fcomponent-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insolar","download_url":"https://codeload.github.com/insolar/component-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insolar%2Fcomponent-manager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269341130,"owners_count":24400787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component-architecture","dependency-injection","golang"],"created_at":"2025-08-07T23:31:39.090Z","updated_at":"2025-08-07T23:32:44.396Z","avatar_url":"https://github.com/insolar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview \n\nComponent Manager provides dependency injection and lifecycle management for component-based monolith architecture apps.\n\nSee [Demo application](https://github.com/AndreyBronin/golang-di-sandbox)\n\n[![Build Status](https://travis-ci.org/insolar/component-manager.svg?branch=master)](https://travis-ci.org/insolar/component-manager)\n[![GolangCI](https://golangci.com/badges/github.com/insolar/component-manager.svg)](https://golangci.com/r/github.com/insolar/component-manager/)\n[![Go Report Card](https://goreportcard.com/badge/github.com/insolar/component-manager)](https://goreportcard.com/report/github.com/insolar/component-manager)\n[![GoDoc](https://godoc.org/github.com/insolar/component-manager?status.svg)](https://godoc.org/github.com/insolar/component-manager)\n[![codecov](https://codecov.io/gh/insolar/component-manager/branch/master/graph/badge.svg)](https://codecov.io/gh/insolar/component-manager)\n\n\n### Features \n- two step initialization\n- reflect based dependency injection for interfaces\n- resolving circular dependency \n- components lifecycle support\n- ordered start, gracefully stop with reverse order\n- easy component and integration tests with mock\n- subcomponents support\n- reduce boilerplate code\n\n## Contetns\n- [Basic usage](#basic-usage)\n    * [Installing](#installing)\n\t* [Component definition](#component-definition)\n\t* [Component lifecycle](#component-lifecycle)\n\n\n## Basic usage\n\n## Installing\nTo start using Component Manager, install Go 1.9 or above and run `go get`:\n\n```sh\n$ go get github.com/insolar/component-manager\n```\n\n\n## Component definition\n\nA Component is a struct which can have dependencies and/or can implement lifecycle interfaces.\n\nDependencies defined as fields in the struct and must be an interface type.\nhave to be exportable because reflect can set only exportable struct fields.\nAlso Dependencies must have tag `inject:\"\"`.\n\n```go\n    type Supermarket struct {\n        Warehouse core.Warehouse `inject:\"\"`\n    }\n\n\tcm := component.NewManager(nil)\n\tcm.Register(producer.NewFarm(), producer.NewDoorFactory())\n\tcm.Register(\u0026supermarket.Supermarket{}, \u0026warehouse.Warehouse{})\n\tcm.Register(NewCustomer(\"Bob\"), NewCustomer(\"Alice\"))\n\tcm.Inject()\n```\n\n## Component lifecycle\n\nUsually components lives from app process executes till process finished. \n\n- new(instance created, first initialization) \n- inject(required dependency injected)\n- init(second initialization)\n- start(component can call their dependency interfaces, run goroutines)\n- prepare stop(optional)\n- stop (gracefully stop goroutines, close descriptors)\n\n### Component constructor\n\nConstructor with config as param.\n\n### Init and start\nWhen should use Init and when Start?\nWhat does it means.\n\n### Stop and gracefully stop\n\ntbd\n\n## intefaces \n\n```go\ntype Initer interface {\n\tInit(ctx context.Context) error\n}\n\ntype Starter interface {\n\tStart(ctx context.Context) error\n}\n\ntype GracefulStopper interface {\n\tGracefulStop(ctx context.Context) error\n}\n\ntype Stopper interface {\n\tStop(ctx context.Context) error\n}\n```\n\n\n## Similar projects\n\n- [facebookgo/inject](https://github.com/facebookgo/inject) - reflect based dependency injector\n- [Uber FX](https://github.com/uber-go/fx) - A dependency injection based application framework\n- [Google Wire](https://github.com/google/wire) - Compile-time Dependency Injection based on code generation\n- [jwells131313/dargo](https://github.com/jwells131313/dargo) - Dependency Injector for GO inspired by Java [HK2](https://javaee.github.io/hk2/)\n- [sarulabs/di](https://github.com/sarulabs/di) - Dependency injection framework for go programs\n                                                   \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsolar%2Fcomponent-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsolar%2Fcomponent-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsolar%2Fcomponent-manager/lists"}