chore: remove useless files
This commit is contained in:
parent
a88ffe1981
commit
d86a21f072
|
@ -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"
|
|
|
@ -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))
|
|
|
@ -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)
|
|
|
@ -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/<string:uuid>')
|
|
||||||
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')
|
|
|
@ -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
|
|
|
@ -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)
|
|
|
@ -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()
|
|
Loading…
Reference in New Issue