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

microcosm
Last synced: 11 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: globality-corp
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 225 KB
Statistics
  • Stars: 36
  • Watchers: 36
  • Forks: 9
  • Open Issues: 1
  • Releases: 0
Archived
Topics
microcosm
Created over 10 years ago · Last pushed about 2 years ago
Metadata Files
Readme Changelog Contributing License

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.

Circle CI

Terminology

  • A microservice is a small software application. It is composed of several smaller pieces of software, many of which are reusable.
  • A component is one of these (possibly reusable) pieces of software.
  • A factory is a function used to create a component; it may be an object's constructor.
  • A config dict is a nested dictionary with string-valued keys. It contains data used by factories to create components.
  • An object graph is a collection of components that may reference each other (acyclically).
  • A binding is 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

  1. Define factory functions for components, attach them to a binding, and provide (optional) configuration defaults:

    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 graph and, through it, the config dict. Default configuration values, if provided, are pre-populated within the provided binding; these may be overridden from data loaded from an external source.

  2. 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`)
  1. Reference any binding in the object graph to access the corresponding component:

    print(graph.foo)
    

    Components are initialized lazily. In this example, the first time graph.foo is accessed, the bound factory (create_foo()) is automatically invoked. Since this factory in turn accesses graph.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.

  2. Optionally, initialize the microservice's components explicitly:

    graph.use(
        "foo",
        "bar",
    )
    

    While the same effect could be achieved by accessing graph.foo or graph.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:

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

  2. Microservices use processes, not threads to scale. As such, thread synchronization is a non-goal.

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

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

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

All Time
  • Total Commits: 167
  • Total Committers: 19
  • Avg Commits per committer: 8.789
  • Development Distribution Score (DDS): 0.521
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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

  • Versions: 56
  • Dependent Packages: 0
  • Dependent Repositories: 19
  • Downloads: 2,187 Last month
Rankings
Dependent repos count: 3.3%
Downloads: 3.8%
Average: 7.9%
Dependent packages count: 10.1%
Stargazers count: 11.0%
Forks count: 11.4%
Maintainers (1)
Last synced: 11 months ago
pypi.org: microcosm-propertygraph

Microcosm Property graph - Conventions for exposing data as a property graph

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 7 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 11.0%
Forks count: 11.9%
Average: 20.4%
Dependent repos count: 21.6%
Downloads: 47.3%
Maintainers (1)
Last synced: 11 months ago

Dependencies

setup.py pypi
  • inflection >=0.3.1
  • lazy >=1.3
Dockerfile docker
  • base latest build
  • deps latest build
  • python slim-stretch build