JSON-RPC

Data validation in AVRO

痞子三分冷 提交于 2020-01-11 05:26:07
问题 I am new to AVRO and please excuse me if it is a simple question. I have a use case where I am using AVRO schema for record calls. Let's say I have avro schema { "name": "abc", "namepsace": "xyz", "type": "record", "fields": [ {"name": "CustId", "type":"string"}, {"name": "SessionId", "type":"string"}, ] } Now if the input is like { "CustId" : "abc1234" "sessionID" : "000-0000-00000" } I want to use some regex validations for these fields and I want take this input only if it comes in

B站直播:使用Golang重构,流量最大的推送功能

随声附和 提交于 2020-01-07 17:51:29
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1 悲剧直播推送功能 1.1 B站直播推送功能的困境 B站直播有个推送功能,就是这里,看到那个红色的数字没有,显示你关注的主播开播人数。 然后每个进入B站的用户,不管是不是直播的观众、不管进入B站哪个页面、不管你要干啥,都要请求一次这个人数接口,直播服务表示:妈逼,就给老子几台土豆服务器,却要扛着跟主站一样PV, 不仅仅是主站在使用这个功能,还有直播服务内部的各种推送心跳同样在使用这个功能,流量很大。 由于主站、直播对于UP主和主播关注是混在一起的,所以每次直播这边都要从一堆用户关注UP主中找到直播的主播,并且还要找到那个主播在直播,老的做法就是从缓存读各种数据,然后遍历,计算,然后输出,对缓存服务器、PHP服务器都造成了极大的压力,然后遇到大的活动,服务器分分钟都是:老子不想干了的节奏。然后大的活动每次都会把推送能关掉,来保证活动正常进行。 1.2 穷则思变的重构 你们以为大佬们一开始就同意我的Golang重构方案吗?你们啊 我苦口婆心的跟大佬们诉说我的方案是多么适合这个业务,然后我Golang技术有多好(无耻笑)、多靠谱,加上在弹幕服务器部门做了一段时间Golang的兼职(没错,是我舔着脸要去的),做了些大流量的功能,他们终于同意了,呵呵,是时候展示真正的技术了(请脑补小黄毛EZ配音)。 1.3

Getting a list of keys from block 0

自古美人都是妖i 提交于 2020-01-06 05:23:32
问题 Using a local blockchain, is it is possible to use the bitcoin-core rpc commands to query a block (such as the genesis block) and get a list of all the public keys used in that block? If it is possible, which commands do I need to use? 回答1: Not entirely. This is because modern outputs contain addresses (technically scriptPubkeys) which are encoded hashes of a public key, see Types of Transactions. Hashes cannot be reversed (or Bitcoin wouldn't work at all), so in order to reveal the public

Web service: RPC vs. RESTful = CISC vs. RISC?

人盡茶涼 提交于 2020-01-03 02:50:08
问题 I read some discussions about RPC style and RESTful web services. So far I have the following 2 thoughts: The argue between RPC and REST seems kind of similar to the argue between CISC and RISC instruction architecture. RPC looks forward to using a more complex vocabulary while REST just use a few common verbs. The REST style just introduce the HTTP protocol as the middle-layer between client and server in the hope to decouple the 2 parties. Just like David Wheeler said: All problems in

How to respond to HTTP OPTIONS request on a JSON-RPC server

女生的网名这么多〃 提交于 2020-01-02 05:23:15
问题 My JSON-RPC client (browser using dojo JSON-RPC) makes a JSON-RPC request (dojo.callRemote) to my JSON-RPC server on myserver.com/12345 (Python 2.5, SimpleJSONRPCServer). The server then gets a HTTP request with header "OPTIONS / HTTP/1.1", which it can't handle by default, so I wrote a custom handler for this request. The request header from the browser says: OPTIONS / HTTP/1.1 Host: myserver:12345 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100214 Linux Mint/8

JSON-RPC Swagger combination

笑着哭i 提交于 2019-12-30 18:47:30
问题 I am considering to implement JSON-RPC for my web service with this library. I would also like to implement Swagger for my service. However, I am not sure, if these two are a good combination together. In JSON-RPC all methods are behind the same resource, while that does not make any sense in Swagger. I am wondering the following: Is it possible to combine these technologies in full strength? Is JSON-RPC still a good technology to use? Or is it better to implement it manually? Your thoughts

Go - JSON-RPC - “too many colons”

时光总嘲笑我的痴心妄想 提交于 2019-12-30 12:04:11
问题 I'm trying to call a HTTP JSON-RPC server for Bitcoin using Go (not on GAE), but I get error of dial tcp http://user:pass@127.0.0.1:8332: too many colons in address or dial ip http://user:pass@127.0.0.1:8332: lookup http://user:pass@127.0.0.1:8332: no such host I tried various network configurations, but couldn't get anything going. When I just typed the address into the browser, I got a response from the server: {"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null} Which

Python Twisted JSON RPC

放肆的年华 提交于 2019-12-28 10:07:39
问题 Can anyone recommend some simple code to set up a simple JSON RPC client and server using twisted? I found txJSON-RPC, but I was wondering if someone had some experience using some of these anc could recommend something. 回答1: txJSONRPC is great. I use it and it works. I suggest you give it a try. SERVER: from txjsonrpc.web import jsonrpc from twisted.web import server from twisted.internet import reactor class Math(jsonrpc.JSONRPC): """ An example object to be published. """ def jsonrpc_add

Python Twisted JSON RPC

半世苍凉 提交于 2019-12-28 10:07:10
问题 Can anyone recommend some simple code to set up a simple JSON RPC client and server using twisted? I found txJSON-RPC, but I was wondering if someone had some experience using some of these anc could recommend something. 回答1: txJSONRPC is great. I use it and it works. I suggest you give it a try. SERVER: from txjsonrpc.web import jsonrpc from twisted.web import server from twisted.internet import reactor class Math(jsonrpc.JSONRPC): """ An example object to be published. """ def jsonrpc_add

python以太坊类库web3.py概览

吃可爱长大的小学妹 提交于 2019-12-27 12:40:09
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> python通过web3.py库与以太坊交互共同入口是 web3 对象。web3对象提供API接口,python开发应用与以太坊进行交互如钱包创建、支付、转账等连接JSON-RPC服务器进行。 Providers提供者 Providers 使web3连接到区块链上。Web3.py库带有以下内置的 providers ,它们能够适用于大多数用例。 web3.HTTPProvider :用于连接基于http和https的JSON-RPC服务器。 web3.IPCProvider :用于连接基于ipc套接字的JSON-RPC服务器。 web3.WebsocketProvider :用于连接基于ws和wss的websocket的JSON-RPC服务器。 HTTPProvider :用于获取可以找到服务器的完整URI。对于本地开发,这类似 http://localhost:8545 。 IPCProvider :用于获取可以找到IPC套接字的文件系统路径。如果不提供任何参数,它将使用操作系统的默认路径。 WebsocketProvider :用于获取可以找到服务器的完整URI。对于本地开发,这类似 ws://127.0.0.1:8546 。 示例代码如下: >>> from web3 import Web3,