该repo,相当于实现了一个小型简单的javascript的vm,用于运行javascript
Going Serverless
Posted on
In
serverless
Serverless,在GCP上部署,采用事件驱动的方式来响应相关的请求
Mongodb Cookbook
Posted on
In
mongodb
###admin
1 | db.currentOp(); |
上面可以做为某些调优手段
Find Documents With An Array Field
$in: [...]
means “intersection” or “any element in”$all: [...]
means “subset” or “contain”$elemMatch: {...}
means “any element match”$not: {$elemMatch: {$nin: [...]}}
means “subset” or “in”
1 | db.getCollection('message').find({ |
Find Documents With Computed Values Using $expr
1 | db.getCollection('user').find({ |
for loop
1 | var oldTags = ['famous', 'newstar', 'featured', 'western', 'recommended', 'popular']; |
python interface
insert an element into an array at certain postion
1 | slot = 2 |
remove elements
采用pull的操作?
1 | import bson |
upsert
1 | tag_schedule = TagSchedule.objects \ |
设置upsert=True
Aggregation Pipeline
$match
: Filters documents.$project
: Modifies document fields.$group
: Groups documents by fields.$lookup
: Joins another collection.$replaceRoot
: Promotes an embedded document field to the top level and replace all other fields.$unwind
: Expanses an array field into multiple documents along with original documents.$facet
: Processes multiple pipelines within one stage and output to different fields.
match multiple condition
1 | import werkzeug |
project负责显示项,unwind负责展开?
Collect Items With $group
And $addToSet
1 | def stages(): |
Do Advanced $project
With $let
If you find youself want to do $project
twice to tackle some fields, you should use $let
.
1 | def stages(): |
Query The First Element In An Array Field With $arrayElemAt
And $filter
1 | def stages(): |
Join Another Collection Using $lookup
1 | def stages(): |
lookup作为join操作
Count Documents In Another Collection With $lookup
(JOIN)
1 | def stages(): |
useful tools
monitoring
1 | $ mongotop |
Rust + Lua
Posted on
In
rust
Grpc 在k8s中的一些使用
Posted on
In
gRpc
stream发送多条命令
1 | rpc SayHelloStreamServer (HelloRequest) returns (stream HelloReply) {} |
这样在client端采用
1 | stream, err := c.SayHelloStreamServer(ctx, &pb.HelloRequest{Name: name}) |
控制rpc service之间的connect时间
1 | ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) |
超过最大size部分
1 | defaultServerMaxReceiveMessageSize = 1024 * 1024 * 4 |
预设大小是4m
1 | func main() { |
这段是改变server端,当然client端也可以改变
在k8s的使用
首先是相关的yaml文件的一个解析部分
结论部分
尝试自己去实现一些基于grpc的服务,client端同server端之间的连接部分