Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.2%) to scientific vocabulary
Keywords
Repository
Basic Info
Statistics
- Stars: 36
- Watchers: 36
- Forks: 9
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
Simple Microservice Configuration
Well-written microservices are small and single-purpose; any non-trivial ecosystem will have a fleet of such services, each performing a different function. Inevitably, these services will use common code and structure; this library provides a simple mechanism for constructing these shared components and wiring them together into services.
Terminology
- A
microserviceis a small software application. It is composed of several smaller pieces of software, many of which are reusable. - A
componentis one of these (possibly reusable) pieces of software. - A
factoryis a function used to create a component; it may be an object's constructor. - A
config dictis a nested dictionary with string-valued keys. It contains data used by factories to create components. - An
object graphis a collection of components that may reference each other (acyclically). - A
bindingis a string-valued key. It is used to identify a component within an object graph and the subsection of the config dict reserved for a component's factory.
Basic Usage
Define factory functions for
components, attach them to abinding, and provide (optional) configurationdefaults:from microcosm.api import defaults, binding @binding("foo") @defaults(baz="value") def create_foo(graph): return dict( # factories can reference other components bar=graph.bar, # factories can reference configuration baz=graph.config.foo.baz, ) @binding("bar") def create_bar(graph): return dict()Factory functions have access to the
object graphand, through it, theconfig dict. Default configuration values, if provided, are pre-populated within the provided binding; these may be overridden from data loaded from an external source.Wire together the microservice by creating a new object graph along with service metadata:
from microcosm.api import create_object_graph graph = create_object_graph( name="myservice", debug=False, testing=False, )Factories may access the service metadata via
graph.metadata. This allows for several best practices:
- Components can implement ecosystem-wide conventions (e.g. for logging or persistence),
using the service name as a discriminator.
- Components can customize their behavior during development (`debug=True`) and unit
testing (`testing=True`)
Reference any
bindingin theobject graphto access the correspondingcomponent:print(graph.foo)Components are initialized lazily. In this example, the first time
graph.foois accessed, the bound factory (create_foo()) is automatically invoked. Since this factory in turn accessesgraph.bar, the next factory in the chain (create_bar()) would also be called if it had not been called yet.Graph cycles are not allowed, although dependent components may cache the graph instance to access depending components after initialization completes.
Optionally, initialize the microservice's components explicitly:
graph.use( "foo", "bar", )While the same effect could be achieved by accessing
graph.fooorgraph.bar, this construction has the advantage of initializes the listed components up front and triggering any configuration errors as early as possible.It is also possible to then disable any subsequent lazy initialization, preventing any unintended initialization during subsequent operations:
graph.lock()
Assumptions
This library was influenced by the pinject project, but makes a few assumption that allow for a great deal of simplication:
Microservices are small enough that simple string bindings suffice. Or, put another way, conflicts between identically bound components are a non-concern and there is no need for explicit scopes.
Microservices use processes, not threads to scale. As such, thread synchronization is a non-goal.
Mocking (and patching) of the object graph is important and needs to be easy. Unit tests expect to use `unittest.mock library; it should be trivial to temporarily replace a component.
Some components will be functions that modify other components rather than objects that need to be instantiated.
Setup
Create a virtualenv
python -m venv venv
. ./venv/bin/activate
Install dependencies
pip install -U -e .
Tests
Run the tests
python setup.py nosetests
Lint
Lint the code:
NAME=microcosm ./entrypoint.sh lint
NAME=microcosm ./entrypoint.sh typehinting
Owner
- Name: Globality, Inc.
- Login: globality-corp
- Kind: organization
- Email: recruiting@globality.com
- Location: Palo Alto (California), London, Tel Aviv
- Website: https://www.globality.com/en-us/careers
- Repositories: 42
- Profile: https://github.com/globality-corp
We use AI to help companies get the best service providers at the right price for every project in order to promote economic inclusion around the world.
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jesse Myers | j****s@g****m | 80 |
| Jesse Myers | j****t@g****m | 17 |
| Pokey Rule | p****e@g****m | 12 |
| cdm-ium | c****m@g****m | 12 |
| Gabriel Lam | g****m@g****m | 11 |
| Avi Zurel | a****i@k****m | 8 |
| Adam Ever Hadani | a****i@g****m | 5 |
| Adrien Fallou | a****u@g****m | 3 |
| Adrien Fallou | a****u | 3 |
| Adam Ever-Hadani | a****i@g****m | 2 |
| albert | a****i@g****m | 2 |
| Sai Raveendran | s****n@g****m | 2 |
| Salman Mashayekh | 4****h | 2 |
| Moshe Zadka | m****z | 2 |
| Rob Hand | 1****n | 2 |
| Pokey Rule | p****e@g****m | 1 |
| Moshe Zadka | m****a@g****m | 1 |
| Salman Mashayekh | s****h@g****m | 1 |
| Rob H | 5****b | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 0
- Total pull requests: 151
- Average time to close issues: N/A
- Average time to close pull requests: 12 days
- Total issue authors: 0
- Total pull request authors: 24
- Average comments per issue: 0
- Average comments per pull request: 0.46
- Merged pull requests: 88
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: about 1 hour
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- jessemyers (19)
- pokey (15)
- GabeLambda (10)
- cdm-ium (7)
- jamie-chang-globality (7)
- german-glob (6)
- afallou (6)
- saivickna (5)
- salmanmashayekh (4)
- adamhadani (4)
- dumpstate (3)
- moshez (3)
- Sinon (2)
- smirco-globality (2)
- GaryGlobality (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 2,194 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 20
(may contain duplicates) - Total versions: 58
- Total maintainers: 1
pypi.org: microcosm
Microcosm - Simple microservice configuration
- Homepage: https://github.com/globality-corp/microcosm
- Documentation: https://microcosm.readthedocs.io/
- License: apache-2.0
-
Latest release: 4.1.0
published about 2 years ago
Rankings
Maintainers (1)
pypi.org: microcosm-propertygraph
Microcosm Property graph - Conventions for exposing data as a property graph
- Homepage: https://github.com/globality-corp/microcosm
- Documentation: https://microcosm-propertygraph.readthedocs.io/
- License: apache-2.0
-
Latest release: 1.1.0
published about 8 years ago
Rankings
Maintainers (1)
Dependencies
- inflection >=0.3.1
- lazy >=1.3
- base latest build
- deps latest build
- python slim-stretch build