Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orders #1

Merged
merged 21 commits into from Oct 24, 2016
Merged

Orders #1

merged 21 commits into from Oct 24, 2016

Conversation

kooba
Copy link
Member

@kooba kooba commented Aug 14, 2016

Orders service.

  • RPC orders CRUD
  • docker image build for nameko/nameko-example-orders:latest
  • CI with circleci
  • 100% test coverage


def delete(self):
if self.deleted_at is None:
self.deleted_at = datetime.datetime.utcnow()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if using our Base is too much for this example. It's a nice pattern but may be confusing since it's non-essential.

Maybe we can keep it but remove the "soft-delete"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We know soft-delete is potentially an anti-pattern. I'll remove it.

@kooba kooba assigned kooba and unassigned kooba Sep 3, 2016
@kooba
Copy link
Member Author

kooba commented Sep 3, 2016

Looking for feedback. @mattbennett @davidszotten @timbu @iky

name = 'orders'

db = DatabaseSession(DeclarativeBase)
order_schema = OrderSchema()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably cleaner to use OrderSchema directly, rather than attaching it as a class attribute.


@pytest.fixture
def container(container_factory, config):
ServiceMeta = namedtuple(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a newer version of this pattern that allows replacement values to be specified.

@@ -0,0 +1,74 @@
import pytest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth a module-level docstring here to define the scope of an "interface" test for a nameko service

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or possibly interface/conftest.py is a better place for it


@pytest.fixture(scope='session')
def db_url():
"""Overriding db_url fixture from nameko_sqlalchemy"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably also need to explain somewhere where the db_session etc fixtures come from, and why these overrides are necessary.


# Run Migrations

alembic upgrade head
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth nothing that you cannot do backwards migrations with this docker container, and that this is just to get you started.

Alternatively we could remove alembic completely from the example app.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would definitely like to keep alembic in the example app. Migrations is a very basic part of any db dependent service. I think we should mention how to support backward migrations in readme for this example alongside of other things that you can find here but are only done for example sake and are not recommended like having multiple services in one repo.

@kooba
Copy link
Member Author

kooba commented Oct 15, 2016

Comments addressed

@@ -23,4 +23,4 @@ alembic upgrade head

# Run Service

nameko run --config config.yml orders.service --backdoor 3000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to show the backdoor here too

RABBIT_PASSWORD: "guest"
RABBIT_USER: "guest"
RABBIT_HOST: "rabbit"
RABBIT_PORT: "15672"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be 5672

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there is a problem here: RABBIT_PORT is used to construct both the AMQP_URI in config.yaml and in run.sh::is_ready(). You need 5672 for one and 15672 for the other.

Copy link

@juliotrigo juliotrigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice! Just a few comments.

version: "2"
services:
rabbit:
container_name: rabbitmq

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These generic container names (rabbitmq, postgres_db, orders) could clash with other existing containers running in the docker machine. Since these are just used for the nameko example, we could prepend some kind of prefix to them to make more explicit what they are used for (like nameko-example-...). What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same. I'll add more explicit prefixes.

'alembic==0.8.7',
'marshmallow==2.9.1',
'psycopg2==2.6.2',
'alembic==0.8.7'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated alembic package.



# @pytest.mark.usefixtures('orders_service')
@pytest.yield_fixture

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yield_fixture is going to be deprecated soon. We could upgrade pytest to the latest version in the setup.py and just use @pytest.fixture here.

return create_service_meta('event_dispatcher')


# @pytest.mark.usefixtures('orders_service')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment here intentionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no 😆

@kooba
Copy link
Member Author

kooba commented Oct 21, 2016

@juliotrigo your comments addressed.

Copy link

@juliotrigo juliotrigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mattbennett mattbennett merged commit f1121d5 into master Oct 24, 2016
@mattbennett mattbennett deleted the orders branch October 24, 2016 11:00
kooba added a commit that referenced this pull request Apr 5, 2018
* k8s Deployment files created

* Ingress added. Fixes to products config file.

* Definitions converted to charts

* Tutorial added

* Readme updates

* Update to Readme

* Nameko loves Kubernetes

* Update to Readme

* Update to readme.

* Update to Readme

* Readme updates

* Bump nameko version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants