python 元类
摘要:创建类的执行流程: 遇到class关键词,执行type的__init__方法,创建Foo类这个对象 遇实例化对象(obj=Foo()),执行type里的__call__方法 在Python中一切皆为对象,class(类)作为模板同样也是对象。 我们可以通过type在运行期间动态创建类,同样我们也可以
阅读全文
posted @
2019-04-29 09:33
chester·chen
阅读(156)
推荐(0) 编辑
docker 多阶段构建
摘要:构建镜像最具挑战性的一点是使镜像大小尽可能的小。Dockerfile中的每条指令都为图像添加了一个图层,您需要记住在移动到下一层之前清理任何不需要的工件。对于多阶段构建,您可以在Dockerfile中使用多个FROM语句。每个FROM指令可以使用不同的基础,并且每个指令都开始一个新的构建。您可以选择
阅读全文
posted @
2019-04-28 16:29
chester·chen
阅读(1700)
推荐(0) 编辑
Kafka consumer的参数
摘要:earliest: 当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,从头开始消费 latest :当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,消费新产生的该分区下的数据 enable_auto_commit (b
阅读全文
posted @
2019-04-28 10:38
chester·chen
阅读(1114)
推荐(0) 编辑
Kafka send问题
摘要:kafka 在send之后不会立即把消息发送到broker。会把消息发到producer所在电脑内存里,后端的IOThread会扫描内存,并从中取出消息进行消费。 在调用close()或者flush()方法之后,会立即将消息发送到broker里。
阅读全文
posted @
2019-04-28 10:36
chester·chen
阅读(1562)
推荐(0) 编辑
.net core 与ELK(5)安装logstash
摘要:1.下载https://www.elastic.co/downloads/logstash到/usr/local/src 2.解压 3.创建配置文件 输入 运行 4.新建测试log文件 写入测试数据:aa 5.打开kibana 新建index partner 查看 至此,简单完成了日志系统,生产中,
阅读全文
posted @
2019-04-10 13:08
chester·chen
阅读(1195)
推荐(1) 编辑
.net core 与ELK(4)后台运行els可视化工具和Kibana
摘要:which nohup .bash_profile中并source加载 如果没有就安装吧 yum provides */nohup nohup npm run start & nohup ./kibana &
阅读全文
posted @
2019-04-10 12:21
chester·chen
阅读(562)
推荐(0) 编辑
.net core 与ELK(3)安装Kibana
摘要:1.去产品官网下载https://www.elastic.co/downloads/kibana 对应的tar.gz的压缩包,放到/usr/local/src目录 2.解压 3.进入到config目录下,进行kibana.yml文件配置 配置端口号,服务器地址,es的地址 4.kibana启动 bi
阅读全文
posted @
2019-04-10 12:14
chester·chen
阅读(994)
推荐(1) 编辑
.net core 与ELK(2)安装Elasticsearch可视化工具
摘要:elasticsearch-head是els的界面插件,地址https://github.com/mobz/elasticsearch-head 1.进入github并下载 2.解压 3.下载node https://nodejs.org/en/download/ 4.配置node环境变量 5.np
阅读全文
posted @
2019-04-10 11:36
chester·chen
阅读(580)
推荐(1) 编辑
.net core 与ELK(1)安装Elasticsearch
摘要:1.安装java jdk [elsearch@localhost bin]$ java -version openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-b13) OpenJDK 64-Bit Serv
阅读全文
posted @
2019-04-10 10:56
chester·chen
阅读(782)
推荐(1) 编辑
django drf 动态权限配置和动态seriaizer_class配置
摘要:可以通过重写get_permissions方法和get_serializers_class方法来实现动态的配置权限和序列化 VIewDemo
阅读全文
posted @
2019-04-06 18:01
chester·chen
阅读(758)
推荐(0) 编辑
django drf 改变retrive的pk查询字段
摘要:lookup_filed可以改变retrive查询时默认以pk查询的逻辑
阅读全文
posted @
2019-04-06 15:46
chester·chen
阅读(843)
推荐(0) 编辑
django drf 权限permission
摘要:https://www.django-rest-framework.org/api-guide/permissions/#custom-permissions PS:可以在view中配置authtication_classes,来指明特定的接口需要授权
阅读全文
posted @
2019-04-06 15:28
chester·chen
阅读(804)
推荐(0) 编辑
django drf unique_together和UniqueTogetherValidator
摘要:联合唯一可以使用django中的unique_together,和DRF中的UniqueTogetherValidator->https://www.django-rest-framework.org/api-guide/validators/#uniquetogethervalidator uni
阅读全文
posted @
2019-04-06 15:08
chester·chen
阅读(1605)
推荐(0) 编辑
django def validate_column和validate
摘要:VIewDemo SerializerDemo
阅读全文
posted @
2019-04-06 11:39
chester·chen
阅读(613)
推荐(0) 编辑
django drf JWT
摘要:建议使用djangorestframework-jwt或者djangorestframework_simplejwt,文档为 https://github.com/GetBlimp/django-rest-framework-jwt https://github.com/davesque/djang
阅读全文
posted @
2019-04-05 16:34
chester·chen
阅读(948)
推荐(0) 编辑
django drf Token验证
摘要:https://www.django-rest-framework.org/api-guide/authentication/#basicauthentication 1.INSTALLED_APPS 2.REST_FRAMEWORK配置 3.migrate生成表 4.创建一个token 5.生成o
阅读全文
posted @
2019-04-05 13:03
chester·chen
阅读(1314)
推荐(0) 编辑
django drf django-filter的method过滤
摘要:1.View Demo 2.SerializerDemo 3.test
阅读全文
posted @
2019-04-05 11:01
chester·chen
阅读(1683)
推荐(0) 编辑
django drf 级联数据和RetrieveModelMixin
摘要:1.定义View 2.定义Serializer 3.配置urls 4.test
阅读全文
posted @
2019-04-05 09:56
chester·chen
阅读(1337)
推荐(0) 编辑
django drf Filter
摘要:1.定义get_queryset()方法 须在urls中指定base_name test 2.django-filter 安装步骤相见文档https://django-filter.readthedocs.io/en/master/guide/install.html https://www.dja
阅读全文
posted @
2019-04-04 19:13
chester·chen
阅读(766)
推荐(0) 编辑
django drf GenericAPIView和ListAPIView
摘要:drf提供了更快捷的查询方法ListModelMixin+GenericAPIView,和ListAPIView 1.ListModelMixin+GenericAPIView 2.ListAPIView 我们可以从源码中看到ListAPIVIew继承了ListModelMixin+GenericA
阅读全文
posted @
2019-04-04 13:50
chester·chen
阅读(1509)
推荐(0) 编辑
django drf 深入ModelSerializer
摘要:serializer用起来稍微麻烦,可以使用ModelSerializer,类似于django里的Form与ModelForm 1.定义ModelSerializer 2.View引用 3.test
阅读全文
posted @
2019-04-04 11:59
chester·chen
阅读(880)
推荐(0) 编辑
django drf 初探serializer
摘要:1.定义Model对应的serializer 2.定义View 3.url配置 4.doc查看
阅读全文
posted @
2019-04-04 10:31
chester·chen
阅读(336)
推荐(0) 编辑
django drf安装和doc生成
摘要:1.打开drf官网https://www.django-rest-framework.org/,把相关的包pip install 2.INSTALLED_APPS添加drf 3.url配置 4.test
阅读全文
posted @
2019-04-04 10:02
chester·chen
阅读(422)
推荐(0) 编辑
django media配置
摘要:当我们需要向服务器发送图片或视频,需要对这些媒体文件进行保存时,需要指定保存在哪并将保存的路径添加到路由中。 1.设置settings.py 2.路由设置 3.获取图片
阅读全文
posted @
2019-04-03 17:19
chester·chen
阅读(133)
推荐(0) 编辑
django model项目外操作
摘要:方法1: 然后import对应的model并操作 方法2: 新建py脚本
阅读全文
posted @
2019-04-03 16:40
chester·chen
阅读(221)
推荐(0) 编辑
django 快捷代码提示
摘要:1.右键项目,Mark Directory As Source Root 2.settings配置 3.import包时可忽略app名了
阅读全文
posted @
2019-04-03 14:32
chester·chen
阅读(429)
推荐(0) 编辑
django静态文件路径配置
摘要:在settings.py中加入 即可在html中引用该目录下的静态文件 效果如下
阅读全文
posted @
2019-04-03 14:14
chester·chen
阅读(536)
推荐(0) 编辑