Skip to content

Commit

Permalink
Finalized v1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
lowjiajin committed Jul 3, 2020
1 parent 8cd97cf commit a7bfb32
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
.DS_Store

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ pip install snowfall
```

### Quickstart
To start generating IDs, simply instantiate a `Snowfall`.
To start generating IDs, simply create a schema group and start a `Snowfall`.
```
from snowfall import Snowfall
from snowfall.generator_syncers import SimpleSyncer
SimpleSyncer.create_schema_group()
id_generator = Snowfall()
```
Successively calling `get_guid()` will return valid GUIDs.
Expand All @@ -49,10 +51,11 @@ The `generator_syncers` module contains classes that enforce this constraint by

#### For single-process projects
For single-process projects, we provide a `SimpleSyncer` that records the manifest as a Python data structure. First, create a new global schema group, and then bind the Snowfall instance to it.

All `Snowfall` instances that share the same schema group will not create duplicate GUIDs.
```
from datetime import datetime
from snowfall import Snowfall
from snowfall.generator_syncers.simple_syncer import SimpleSyncer
from snowfall.generator_syncers import SimpleSyncer
SimpleSyncer.create_schema_group(
schema_group_name="example_schema_group"
Expand Down Expand Up @@ -84,7 +87,7 @@ For multi-process, multi-container projects, we need to persist the `generator_i
```
from datetime import datetime
from snowfall import Snowfall
from snowfall.generator_syncers.database_syncer import DatabaseSyncer
from snowfall.generator_syncers import DatabaseSyncer
DatabaseSyncer.create_schema_group(
schema_group_name="example_schema_group"
Expand Down
1 change: 1 addition & 0 deletions snowfall/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from snowfall.main import Snowfall
3 changes: 3 additions & 0 deletions snowfall/generator_syncers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from snowfall.generator_syncers.abstracts import BaseSyncer
from snowfall.generator_syncers.database_syncer import DatabaseSyncer
from snowfall.generator_syncers.simple_syncer import SimpleSyncer
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
from apscheduler.schedulers.background import BackgroundScheduler

from utils import get_current_timestamp_ms
from snowfall.utils import get_current_timestamp_ms


class BaseSyncer(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.engine.base import Engine

from generator_syncers.abstracts import BaseSyncer
from utils import get_current_timestamp_ms
from snowfall.generator_syncers.abstracts import BaseSyncer
from snowfall.utils import get_current_timestamp_ms


class DatabaseSyncer(BaseSyncer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from collections import namedtuple
import numpy as np

from generator_syncers.abstracts import BaseSyncer
from utils import get_current_timestamp_ms
from snowfall.generator_syncers.abstracts import BaseSyncer
from snowfall.utils import get_current_timestamp_ms


SchemaGroup = namedtuple(
Expand Down
4 changes: 2 additions & 2 deletions src/main.py → snowfall/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from datetime import datetime
from time import sleep

from generator_syncers import BaseSyncer, SimpleSyncer
from utils import get_current_timestamp_ms
from snowfall.generator_syncers import BaseSyncer, SimpleSyncer
from snowfall.utils import get_current_timestamp_ms


class Snowfall:
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion src/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions src/generator_syncers/__init__.py

This file was deleted.

0 comments on commit a7bfb32

Please sign in to comment.