grpc

Is “google/protobuf/struct.proto” the best way to send dynamic JSON over GRPC?

醉酒当歌 提交于 2020-12-29 05:48:19
问题 I have a written a simple GRPC server and a client to call the server (both in Go). Please tell me if using golang/protobuf/struct is the best way to send a dynamic JSON with GRPC. In the example below, earlier I was creating Details as a map[string]interface{} and serializing it. Then I was sending it in protoMessage as bytes and was de-serializing the message on the server side. Is it the best/efficient way to do it or should I define Details as a struct in my proto file? Below is User

golang protobuf remove omitempty tag from generated json tags

青春壹個敷衍的年華 提交于 2020-12-28 07:04:45
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

golang protobuf remove omitempty tag from generated json tags

浪子不回头ぞ 提交于 2020-12-28 06:56:28
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

golang protobuf remove omitempty tag from generated json tags

烂漫一生 提交于 2020-12-28 06:50:27
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

golang protobuf remove omitempty tag from generated json tags

我怕爱的太早我们不能终老 提交于 2020-12-28 06:47:31
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

服务器端编程语言对比:C/C++, C#.NET, Java, Go, Rust

若如初见. 提交于 2020-12-28 01:23:30
对比指标 C/C++ C#.NET Java Go Rust 计算斐波那契数列第60个数字(循环实现) 计算斐波那契数列第10个数字(递归实现) uint16比特位的设置 uint16比特位的查找 自定义快速排序 自定义stack的pop/push 自定义链表的构建 自定义链表的查找 Protobuf消息编码 Protobuf消息解码 AES加密 AES解密 并发读写数据 格式化日志 申请48byte内存 自定义类型初始化 责任链方法调用 JSON编解码 内存直接拷贝 对象复制 字符串匹配 hashmap性能 自定义html解析 自定义html解析 获取当前时间戳 打印64k行日志 斐波那契数列三层调用处理(GRPC框架) 斐波那契数列三层调用处理(自定义框架) 来源: oschina 链接: https://my.oschina.net/u/4271269/blog/4845045

Serverless 架构的演进

吃可爱长大的小学妹 提交于 2020-12-25 10:18:10
The Serverless Framework (无服务器架构)允许你自动扩展、按执行付费、将事件驱动的功能部署到任何云。 目前支持 AWS Lambda、Apache OpenWhisk、Microsoft Azure,并且正在扩展以支持其他云提供商。 Serverless 降低了维护应用程序的总成本,能够更快地构建更多逻辑。它是一个 命令 行工具,提供脚手架、工作流自动化和开发部署无服务器架构的最佳实践。它也可以通过插件完全扩展。 传统单体应用架构 十多年前主流的应用架构都是单体应用,部署形式就是一台服务器加一个数据库,在这种架构下,运维人员会小心翼翼地维护这台服务器,以保证服务的可用性。 ▲ 单体架构 单体应用架构面临的问题 随着业务的增长,这种最简单的单体应用架构很快就面临两个问题。首先,这里只有一台服务器,如果这台服务器出现故障,例如硬件损坏,那么整个服务就会不可用;其次,业务量变大之后,一台服务器的资源很快会无法承载所有流量。 解决这两个问题最直接的方法就是在流量入口加一个负载均衡器,使单体应用同时部署到多台服务器上,这样服务器的单点问题就解决了,与此同时,这个单体应用也具备了水平伸缩的能力。 ▲ 单体架构(水平伸缩) 微服务架构 1. 微服务架构演进出通用服务 随着业务的进一步增长,更多的研发人员加入到团队中,共同在单体应用上开发特性

Kubernetes-整体概述和架构

我是研究僧i 提交于 2020-12-25 07:23:41
↑点击上方 “ kubernetes中文社区 ” 关注我们 1、Kubernetes是什么 Kubernetes是一个轻便的和可扩展的开源平台,用于管理容器化应用和服务。通过Kubernetes能够进行应用的自动化部署和扩缩容。在Kubernetes中,会将组成应用的容器组合成一个逻辑单元以更易管理和发现。Kubernetes积累了作为Google生产环境运行工作负载15年的经验,并吸收了来自于社区的最佳想法和实践。Kubernetes经过这几年的快速发展,形成了一个大的生态环境,Google在2014年将Kubernetes作为开源项目。Kubernetes的关键特性包括: 自动化装箱 :在不牺牲可用性的条件下,基于容器对资源的要求和约束自动部署容器。同时,为了提高利用率和节省更多资源,将关键和最佳工作量结合在一起。 自愈能力: 当容器失败时,会对容器进行重启;当所部署的Node节点有问题时,会对容器进行重新部署和重新调度;当容器未通过监控检查时,会关闭此容器;直到容器正常运行时,才会对外提供服务。 水平扩容 :通过简单的命令、用户界面或基于CPU的使用情况,能够对应用进行扩容和缩容。 服务发现和负载均衡 :开发者不需要使用额外的服务发现机制,就能够基于Kubernetes进行服务发现和负载均衡。 自动发布和回滚 :Kubernetes能够程序化的发布应用和相关的配置

关于API微服务网关

匆匆过客 提交于 2020-12-23 19:01:23
背景 我们都知道,在微服务架构风格里,一个应用会被拆分成多个小的服务系统,并且这些小系统都可以自成体系,可以拥有自己的数据库、框架语言等。它们通常都可以提供接口来被各种应用程序调用。 但是在UI上进行展示的时候,我们通常需要在一个界面上展示很多数据,这些数据可能来自于不同的微服务中。 打个比方:要查看一个电商平台的商品详情页,这个商品详情页包括标题、价格、库存、评价等等,这些数据可能在不同的微服务系统之中,如下所示: • 产品 - 负责提供商品的标题,描述,规格等。 • 价格 - 负责对产品进行定价,价格策略计算,促销价等。 • 库存 - 负责产品库存。 • 评价 - 负责用户对商品的评论,回复等。 现在,商品详情页需要从这些微服务中拉取相应的信息,问题来了? 由于用的是多个服务系统的架构,所以依靠单个数据库的 join 查询结果不可行,那么该怎么访问各个服务呢? 按照微服务设计的指导原则,我们的微服务可能存在下面的问题: • 服务使用了多种协议,因为不同的协议有不同的应场景用,比如可能同时使用 HTTP, AMQP, gRPC 等。 • 服务的划分可能随着时间而变化。 • 服务的实例或者Host+端口可能会动态的变化。 那么,对于前端的UI需求也可能会有以下几种: • 粗粒度的API,而微服务通常提供的细粒度的API,对于UI来说如果要调用细粒度的api可能需要调用很多次

Go微服务入门到容器化实践,落地可观测的微服务电商项目

丶灬走出姿态 提交于 2020-12-20 00:13:54
Go微效勞入門到容器化理論,落地可觀測的微效勞電商項目 下载地址: 百度云盘 關於真正微效勞項目來說,效勞開發只是第一步,容器化、弹性伸缩和可觀測才是真正關键。本课程將經過電商項目實戰,係統學習完整形態的微效勞,控製成熟閉環的落中央案。 技術請求 有Go實践開發經歷 控製Linux操作 純熟控製MySQL 環境參數 開發言语:Golang 開發平台:Windows 10 開發工具:GoLand 章節目錄: 第1章 课程引見與學習指南 試看 课程的引見、學習道路與指南,如何更好的學習本课程 共 1 節 (6分鍾) 收起列表 1-1 本课的go微效勞有什麼不同? (05:34) 試看 第2章 Go微效勞引見與容器化入門 試看 课程是以go-micro爲主的技術栈,本章解說其transport通訊層grpc原理。以及grpc數據的傳輸序列化和反序列化protobuf的原理 共 6 節 (101分鍾) 收起列表 2-1 微效勞根底引見 (19:17) 2-2 微效勞必備技藝Docker 入門引見 (18:48) 2-3 go-micro根底之 grpc protogo-micro 組件架構及通訊原理 (12:28) 試看 2-4 go-micro根底之 grpc proto (20:29) 2-5 go-micro 入門案例考證 (14:41) 2-6 go-micro 入門案例編寫