微服务(MicroServices)资料整理

微服务单篇文章

解析微服务架构

 

微服务框架

Golang

  • https://github.com/go-kit/kit
  • https://github.com/micro/micro
  • https://github.com/NYTimes/gizmo
  • 直接使用gRPC

微服务实战

英文

中文

RPC REST相关

安全

实践

其他

# Golang Build 官方发布 #

Sublime Text build system integration packages

Gophers,

This is our first stable release of a set of Sublime Text packages (v0.9.0):

  • ‘golangconfig’ is a developer library used to obtain information about the local Go environment. It handles configuration ($GOPATH, etc) through a combination of auto-detection and configuration. It is designed to be used by other Go-related Sublime Text packages.
  • ‘Golang Build’ provides Go toolchain integration with the Sublime build system – go build, go run, go install, go test. It is the first package to utilize the functionality of golangconfig.

Golang Build can be installed via packagecontrol.io:

  1. If you don’t already have Package Control installed, follow these instructions.
  2. Run the “Install Package” command via the command palette
  3. Type “Golang Build” and press enter

User documentation for Golang Build is available here. If you’d like to contribute to either package, there is also complete developer documentation available on Github (golangconfigGolang Build).


Please file bugs using the appropriate issue trackers on Github. For problems with Go environment detection and configuration, issues should be filed at:

For bugs related to the build command integration, issues should be filed at:

Our goal is to have other Go-related Sublime packages adopt golangconfig. This would allow users to set their Go environment configuration in one place and have that used by all of their installed Go/Sublime packages. If you are an author of a Go-related Sublime Text package, we’d love to hear your feedback on golangconfig.

Happy Editing,
The Go Team

Sublime Text 安装 GO说明

想必已经安装了st的插件管理器

直接安装名称为 “Golang Build “即可

Golang Build 源码  

Golang Build

Golang Build 文档

Golang Build 使用文档

 

故障现象

微信服务号发送模版消息失败,生成事件二维码图片也失败

代码没有任何改动,莫名其妙就这样了

# 调试过程
检查后发现如下返回错误

{
“errcode”: 40001,
“errmsg”: “invalid credential, access_token is invalid or not latest”
}
{
“errcode”: 40001,
“errmsg”: “invalid credential, access_token is invalid or not latest”
}
检查微信所有api相关参数是否正确,检查都是对的
重新获取新的access_token测试能通过
一度怀疑是不是缓存有效期是不是出问题了
过期了应该是下图的样子42001,而不是40001呀

{
“errcode”: 42001,
“errmsg”: “access_token expired”
}
 
 
{
“errcode”: 42001,
“errmsg”: “access_token expired”
}
https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=CM2Dt8rXdcMB5k_In4mGRF6M2jT_NYAakU4RyrHyj1uRXNxdmupGDRhWYA_DSgG_LRgcwXRbsJCVrR5IVBl5rx3jNRyo-T_xPTJ4ZhrjCxc
 

找到问题

http://segmentfault.com/q/1010000002998425
最后一句话点醒了我
yi5344 说道 access_token的有效期目前为2个小时,需定时刷新,重复获取将导致上次获取的access_token失效。
 
突然想起来,在我们的系统当中有两处独立的微信公众号SDK调用,缓存access_token是独立工作的。
对于同一个微信公众号来说 access_token 是一把钥匙。
如果本地access_token多处单独存储和缓存,这样会导致多处都去更新微信api中access_token值,当更新发生的时候这样只有一处是正常的,其他地方本地的access_token就失效了。
 

解决方法

对于同一个微信公众账号的  access_token 只能存储在一个地方。

0x00 用flash URLLoader 支持跨域提交

除了IOS外全支持

0x01 用CORS支持跨域提交

需要浏览器IE8+

ox02 用jsonp支持跨域提交

只支持get方式

 

参考文献

W3C标准 Cross-Origin Resource Sharing

Adobe 了解跨域资源共享 (CORS)

whitenegro关于AJAX/javascript 跨域访问的解决办法及 CORS(Cross-Origin Resource Sharing) 简单介绍

javascript最全的10种跨域共享的方法

编译安装配置

wget http://pecl.php.net/get/xhprof-0.9.4.tgz
tar zxvf xhprof-0.9.4.tgz 
cd xhprof-0.9.4
cd extension/
/usr/bin/phpize
./configure 
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vim /usr/local/php/etc/php.ini

EOF<<<
[xhprof]
extension=xhprof.so;
xhprof.output_dir=/home/wwwroot/iamle.com/xhprof 
EOF

mkdir -p /home/wwwroot/iamle.com/xhprof
cd ..
cp -rv examples/ xhprof_html/ xhprof_lib/ /home/wwwroot/iamle.com/xhprof
/etc/init.d/php-fpm reload

例子用法

http://localhost/xhprof/examples/sample.php

http://localhost/xhprof/xhprof_html/index.php?run=5455f9208a2eb&source=xhprof_foo

xhprof的名词解释

Function Name 函数名
Calls 调用次数
Calls% 调用百分比
Incl. Wall Time (microsec) 调用的包括子函数所有花费时间 以微秒算(一百万分之一秒)
IWall% 调用的包括子函数所有花费时间的百分比
Excl. Wall Time (microsec) 函数执行本身花费的时间,不包括子树执行时间,以微秒算(一百万分之一秒)
EWall% 函数执行本身花费的时间的百分比,不包括子树执行时间
Incl. CPU(microsecs) 调用的包括子函数所有花费的cpu时间。减Incl. Wall Time即为等待cpu的时间
减Excl. Wall Time即为等待cpu的时间
ICpu% Incl. CPU(microsecs)的百分比
Excl. CPU(microsec) 函数执行本身花费的cpu时间,不包括子树执行时间,以微秒算(一百万分之一秒)。
ECPU% Excl. CPU(microsec)的百分比
Incl.MemUse(bytes) 包括子函数执行使用的内存。
IMemUse% Incl.MemUse(bytes)的百分比
Excl.MemUse(bytes) 函数执行本身内存,以字节算
EMemUse% Excl.MemUse(bytes)的百分比
Incl.PeakMemUse(bytes) Incl.MemUse的峰值
IPeakMemUse% Incl.PeakMemUse(bytes) 的峰值百分比
Excl.PeakMemUse(bytes) Excl.MemUse的峰值
EPeakMemUse% EMemUse% 峰值百分比