第一种: private bool IsDefaultValue(T value) { Span<byte> valueBytes = MemoryMarshal.AsBytes<T>(new T []{ value }.AsSpan()); var defaultBytes = new byte[valueBytes.Length]; return valueBytes.SequenceEqual(defaultBytes); } 第二种: public class Test<T&g…
第一种: private bool IsDefaultValue(T value) { Span<byte> valueBytes = MemoryMarshal.AsBytes<T>(new T []{ value }.AsSpan()); var defaultBytes = new byte[valueBytes.Length]; return valueBytes.SequenceEqual(defaultBytes); } 第二种: public class Test<T&g…
<ItemGroup> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0-preview.2.22152.2" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0-preview.2.22152.2&qu…
<ItemGroup> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0-preview.2.22152.2" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0-preview.2.22152.2" /> <PackageReference Include="…
Using interfaces has another benefit: it facilitates mocking. To evaluate whether your code is good, properly separated, or over-designed, write comprehensive unit tests for yourself. If it's difficult or impossible to write unit tests for your own code, then …
Packages: Microsoft.AspNetCore.Mvc.Testing Microsoft.AspNetCore.TestHost Moq Integration testing can ensure that application components are functioning correctly at levels that include application support infrastructure such as databases, file systems, and net…
包: Microsoft.AspNetCore.Mvc.Testing Microsoft.AspNetCore.TestHost Moq 集成测试可在包含应用支持基础结构(如数据库、文件系统和网络)的级别上确保应用组件功能正常。 ASP.NET Core 通过将单元测试框架与测试 Web 主机和内存中测试服务器结合使用来支持集成测试。 集成测试确认两个或更多应用组件一起工作以生成预期结果,可能包括完整处理请求所需的每个组件。 这些更广泛的测试用于测试应用的基础结构和整个框架,通常包括以下组件: 数据库 文件系统 …
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Running; public unsafe class Model { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } private static Model _model = new Mode…
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Running; public unsafe class Model { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } private static Model _model = new Mode…
What is DDD Domain Model What is a domain model? A domain model is a software model that pertains to a specific business domain. Typically, a domain model is implemented through an object model that encapsulates both data and behavior, expressing accurate busi…
提前配置 mysql,然后通过 docker 单机配置启动 NACOS。 docker run -itd -p 8848:8848 -p 9848:9848 -p 9849:9849 -e SPRING_DATASOURCE_PLATFORM=mysql -e MYSQL_SERVICE_HOST=192.168.0.0 \ -e MYSQL_SERVICE_DB_NAME=nacos -e MYSQL_SERVICE_PORT=3306 -e MYSQL_SERVICE_USER=root -e MYSQL_SE…
提前配置 mysql,然后通过 docker 单机配置启动 NACOS。 docker run -itd -p 8848:8848 -p 9848:9848 -p 9849:9849 -e SPRING_DATASOURCE_PLATFORM=mysql -e MYSQL_SERVICE_HOST=192.168.0.0 \ -e MYSQL_SERVICE_DB_NAME=nacos -e MYSQL_SERVICE_PORT=3306 -e MYSQL_SERVICE_USER=root -e MYSQL_SE…
Docker Apache Pulsar is a cloud-native distributed messaging and streaming platform originally created by Yahoo!. It is now a top-level project of the Apache Software Foundation. pulsar-manager is a web tool for managing Pulsar. https://github.com/apache/pulsa…
Docker Apache Pulsar 是一个云原生的分布式消息传递和流媒体平台,最初由 Yahoo! 创建。现在是顶级 Apache 软件基金会项目. 而 pulsar-manager 是管理 Pulsar 的一个 web 工具。 https://github.com/apache/pulsar-manager Docker 部署 Pulsar 和 Pulsar-manager docker pull apachepulsar/pulsar:latest docker run -d -it \ -p 6650:…
Kubernetes Logging and EFK Logging Solution This article mainly references the following two articles and integrates and translates their contents. https://devopscube.com/kubernetes-logging-tutorial/ https://devopscube.com/setup-efk-stack-on-kubernetes/ Part O…
Kubernetes 日志 和 EFK 日志方案 本文主要参考以下两个文章,对文章内容进行翻译整合。 https://devopscube.com/kubernetes-logging-tutorial/ https://devopscube.com/setup-efk-stack-on-kubernetes/ 第一部分:Kubernetes 日志 在这个 Kubernetes 日志教程中,您将学习 Kubernetes 集群日志中涉及的关键概念和工作流。 当涉及到 Kubernetes 生产调试时,日志起着至关重…
During the New Year's holiday, I studied some domain-driven design knowledge. Here is a summary. In domain-driven design, layered architecture is an important part, so let's start with layering and gradually understand some concepts in DDD. Data Mapping Layer …
过年假期在学习了一些领域驱动知识,这里做个汇总。 在领域驱动设计中,程序进行分层,是其重要的一部分,因此这里以分层开始,逐步了解 DDD 中的一些概念。 数据映射层 首先第一步是数据库,数据库这一部分是持久层,负责实体对象和数据库表的映射以及数据库连接配置、数据库上下文配置、ORM 配置等,数据库和缓存它们都是供领域层使用,但是不能直接使用,而是通过仓储的封装。 对于数据库表,在程序中使用实体来对应数据库表,而作为持久层,持久化对象称为 Persistent Object,缩写是 PO,表示持久化的对象。因为实体叫…
Kubernetes Monitoring When your application is deployed to Kubernetes, it becomes challenging to see what is happening inside the containers. Once a container dies, the data inside it may be permanently lost, and you might not even be able to view the logs to …