Service Mesh:每位开发者都需要了解的热门技术

编者按:本文由 SolarMesh 团队进行编写,全文约6000字,阅读约需10分钟。
SolarMesh 目前已提供了下载体验版,如果您想了解和体验更多 Service Mesh 的功能,不妨来 官网 免费体验一下。

在这里插入图片描述

近几年,Service Mesh这个概念如火如荼,尤其是经常和后端系统打交道的软件工程师,对这个词应该不陌生。随着技术的发展,网上关于Service Mesh的文章日益增多,但是在一些问题上剖析得还不够到位。本文将结合国外部分文章,提供一个深入可靠的、以工程师为中心的Service Mesh指南,解决“什么是服务网格”“为什么要用服务网格”等问题,相信读完文章的你将有所收获。

什么是服务网格?

大约从 2017 年开始,Service Mesh 这个名词逐渐进入国内开发者的视野,人们开始关注其前沿发展。一般认为 Service Mesh 是由开发 Linkerd 的 Buoyant 公司提出的。Linkerd 的 CEO William Morgan 曾给 Service Mesh 这样一个定义:

The service mesh is typically implemented as a scalable set of network proxies deployed alongside application code (a pattern sometimes called a sidecar). These proxies handle the communication between the microservices and also act as a point at which the service mesh features can be introduced. The proxies comprise the service mesh’s data plane, and are controlled as a whole by its control plane.[1]
Service Mesh(服务网格)是一个专用基础设施层,用于处理服务间通信。它负责在有着复杂的服务拓扑的现代云原生应用中实现请求的可靠传递。在实践中,服务网格通常实现为一组轻量级网络代理,与应用程序部署在一起,而对应用程序透明。

在大部分讨论中,对服务网格的描述都显得很简单:『它是一组部署在业务服务旁的代理』。这些代理通常被称作服务网格的『数据面』,并将其管理进程定义为『控制面』。数据面负责拦截并处理服务之间的调用;控制面则负责协调代理的行为,并为操作人员提供一组 API 来操作服务网格。

这些代理通常被称作服务网格的『数据面』,并将其管理进程定义为『控制面』。数据面负责拦截并处理服务之间的调用;控制面则负责协调代理的行为,并为操作人员提供一组 API 来操作服务网格。
图片
更具体地说,这些代理类似于 HAProxy 和 Nginx 的 7 层 TCP 代理,它们会负责发起和响应服务间的请求(实际上,它们同时扮演 “代理”和“反向代理” 的角色,处理流量的流入和流出),并对服务间调用提供了一个功能集合。服务网格代理与其他的API网关或入口

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
非常感谢您的指正,您说的是对的,OpenMesh库中确实没有 `OpenMesh::IO::read_texture` 函数。我想提供一个修改过的示例代码,以使用 OpenMesh 的 `OMFormat` 类型和 `OpenMesh::IO::read` 函数来读取带纹理的网格文件。以下是新的示例代码: ```c++ #include <iostream> #include <OpenMesh/Core/IO/MeshIO.hh> #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> struct MyTraits : public OpenMesh::DefaultTraits { typedef OpenMesh::Vec3d Point; typedef OpenMesh::Vec3d Normal; typedef OpenMesh::Vec2d TexCoord2D; }; typedef OpenMesh::TriMesh_ArrayKernelT<MyTraits> MyMesh; int main(int argc, char **argv) { MyMesh mesh; if (!OpenMesh::IO::read(mesh, "my_mesh.obj")) { std::cerr << "Failed to read mesh file!" << std::endl; return 1; } // Check if the mesh has texture coordinates if (!mesh.has_vertex_texcoords2D()) { std::cerr << "Mesh doesn't have texture coordinates!" << std::endl; return 1; } // Read texture coordinates if (!OpenMesh::IO::read_texture(mesh, "my_texture.png")) { std::cerr << "Failed to read texture file!" << std::endl; return 1; } // Access texture coordinates for (MyMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end(); ++v_it) { MyMesh::TexCoord2D texCoord = mesh.texcoord2D(*v_it); std::cout << "Vertex " << *v_it << " has texture coordinates (" << texCoord[0] << ", " << texCoord[1] << ")" << std::endl; } return 0; } ``` 这个示例使用 `OpenMesh::IO::read` 函数来读取网格文件,该函数会根据文件扩展名自动选择正确的文件格式。纹理文件仍然需要是 PNG 格式。另外请注意,如果您在使用自定义 traits 类型时需要读取不同的属性,请相应地修改 traits 类型的定义。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值