diff --git a/examples/__init__.py b/examples/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/apiflask_demo/__init__.py b/examples/apiflask_demo/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/nameko_demo/__init__.py b/examples/nameko_demo/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/nameko_demo/config.yml b/examples/nameko_demo/config.yml deleted file mode 100644 index acf0bf2..0000000 --- a/examples/nameko_demo/config.yml +++ /dev/null @@ -1,24 +0,0 @@ -AMQP_URI: pyamqp://${RABBIT_USER:guest}:${RABBIT_PASSWORD:guest}@${RABBIT_HOST:localhost}:${RABBIT_PORT:5672}/ -RPC_EXCHANGE: 'nameko-rpc' - -max_workers: 10 -parent_calls_tracked: 20 - -LOGGING: - version: 1 - formatters: - tracer: - (): nameko_tracer.formatters.PrettyJSONFormatter - handlers: - tracer: - class: logging.StreamHandler - formatter: tracer - loggers: - nameko_tracer: - level: INFO - handlers: [tracer] - -SENTRY: - DSN: "xxxx" - CLIENT_CONFIG: - site: "my site name" \ No newline at end of file diff --git a/examples/nameko_demo/demo.py b/examples/nameko_demo/demo.py deleted file mode 100644 index 819e668..0000000 --- a/examples/nameko_demo/demo.py +++ /dev/null @@ -1,48 +0,0 @@ -import json -import datetime -import requests -from nameko.web.handlers import http -from nameko.timer import timer -from statsd import StatsClient -from circuitbreaker import circuit -from chassis.chassis import init_logger, init_statsd, init_sentry -from config.config import Config - - -class DemoChassisService: - name = "demo_chassis_service" - - sentry = init_sentry() - statsd = init_statsd(Config.STATSD_PERMISSION_PREFIX, Config.STATSD_HOST, Config.STATSD_PORT) - logger = init_logger() - - @http('GET', '/health') - @statsd.timer('health') - def health(self, _request): - return json.dumps({'ok': datetime.datetime.utcnow().__str__()}) - - @http('GET', '/external') - @circuit(failure_threshold=5, expected_exception=ConnectionError) - @statsd.timer('external') - def external_request(self, _request): - response = requests.get('https://jsonplaceholder.typicode.com/posts/1') - return json.dumps({'code': response.status_code, 'body': response.text}) - - @http('GET', '/error') - @circuit(failure_threshold=5, expected_exception=ZeroDivisionError) - @statsd.timer('http_error') - def error_http_request(self): - return json.dumps({1 / 0}) - - -class HealthCheckService: - name = "health_check_service" - - statsd = StatsClient('localhost', 8125, prefix='simplebank-nameko_demo') - - @timer(interval=10) - @statsd.timer('check_demo_service') - def check_demo_service(self): - response = requests.get('http://0.0.0.0:8000/health') - print("DemoChassisService HEALTH CHECK: status_code {}, response: {}".format( - response.status_code, response.text)) diff --git a/examples/nameko_demo/events_demo.py b/examples/nameko_demo/events_demo.py deleted file mode 100644 index be5195e..0000000 --- a/examples/nameko_demo/events_demo.py +++ /dev/null @@ -1,41 +0,0 @@ -from nameko.events import BROADCAST, EventDispatcher, event_handler -from nameko.rpc import rpc -from nameko.timer import timer - - -class EventPublisherService: - name = "publisher_service" - - dispatch = EventDispatcher() - - @rpc - def publish(self, event_type, payload): - self.dispatch(event_type, payload) - - -class AnEventListenerService: - name = "an_event_listener_service" - - @event_handler("publisher_service", "an_event") - def consume_an_event(self, payload): - print("service {} received:".format(self.name), payload) - - -class AnotherEventListenerService: - name = "another_event_listener_service" - - @event_handler("publisher_service", "another_event") - def consume_another_event(self, payload): - print("service {} received:".format(self.name), payload) - - -class ListenBothEventsService: - name = "listen_both_events_service" - - @event_handler("publisher_service", "an_event") - def consume_an_event(self, payload): - print("service {} received:".format(self.name), payload) - - @event_handler("publisher_service", "another_event") - def consume_another_event(self, payload): - print("service {} received:".format(self.name), payload) diff --git a/examples/nameko_demo/http_demo.py b/examples/nameko_demo/http_demo.py deleted file mode 100644 index 25e4b3a..0000000 --- a/examples/nameko_demo/http_demo.py +++ /dev/null @@ -1,25 +0,0 @@ -import json -from nameko.web.handlers import http -from werkzeug.wrappers import Response -from nameko_sentry import SentryReporter - - -class HttpDemoService: - name = "http_demo_service" - sentry = SentryReporter() - - @http("GET", "/broken") - def broken(self, request): - raise ConnectionRefusedError() - - @http('GET', '/books/') - def demo_get(self, request, uuid): - data = {'id': uuid, 'title': 'The unbearable lightness of being', - 'author': 'Milan Kundera'} - return Response(json.dumps({'book': data}), - mimetype='application/json') - - @http('POST', '/books') - def demo_post(self, request): - return Response(json.dumps({'book': request.data.decode()}), - mimetype='application/json') diff --git a/examples/nameko_demo/requirements.txt b/examples/nameko_demo/requirements.txt deleted file mode 100644 index cebedab..0000000 --- a/examples/nameko_demo/requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -nameko==2.14.1 -nameko-tracer==1.4.0 -logstash_formatter==0.5.17 -statsd==4.0.1 -gutter==0.5.0 -nameko-sentry==1.0.0 -tenacity==8.2.2 -cachetools==5.3.0 -circuitbreaker==2.0.0 - - -# pyopenssl==23.1.1 \ No newline at end of file diff --git a/examples/nameko_demo/rpc_demo.py b/examples/nameko_demo/rpc_demo.py deleted file mode 100644 index 843d1a7..0000000 --- a/examples/nameko_demo/rpc_demo.py +++ /dev/null @@ -1,20 +0,0 @@ -from nameko.rpc import rpc, ServiceRpc - - -class RpcResponderDemoService: - name = "rpc_responder_demo_service" - - @rpc - def hello(self, name): - return "Hello, {}!".format(name) - - -class RpcCallerDemoService: - name = "rpc_caller_demo_service" - - remote = ServiceRpc("rpc_responder_demo_service") - - @rpc - def remote_hello(self, value="John Doe"): - res = u"{}".format(value) - return self.remote.hello(res) diff --git a/examples/timer_demo/__init__.py b/examples/timer_demo/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/timer_demo/timer.py b/examples/timer_demo/timer.py deleted file mode 100644 index 238705a..0000000 --- a/examples/timer_demo/timer.py +++ /dev/null @@ -1,13 +0,0 @@ -from rocketry import Rocketry -from rocketry.conds import daily - -app = Rocketry() - - -@app.task(daily) -def do_daily(): - print('日常任务') - - -if __name__ == '__main__': - app.run() \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e69de29..0000000