Skip to content

core-go/overview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

Overview

What is a Microservice

A microservice is an architectural style that structures an application as a collection of small, loosely coupled, independently deployable services. Each service typically focuses on a specific business capability and can be developed, deployed, and scaled independently. Microservices communicate with each other through well-defined APIs, often using lightweight protocols such as HTTP/REST, gRPC, or messaging queues.

Microservice Architect

Comparison: Microservice vs. Monolithic Architecture

Monolithic Architecture

  • Structure: A single, unified codebase where all components are tightly integrated.
  • Deployment: Deployed as a single unit. Any change or update requires redeploying the entire application.
  • Development: Usually simpler to develop initially but can become complex and difficult to manage as the application grows.
  • Scaling: Scaling requires scaling the entire application, even if only a small part of it requires more resources.

Microservice Architecture

  • Structure: Composed of multiple, independent services, each responsible for a specific business function.
  • Deployment: Each service can be deployed independently, allowing for continuous deployment and updates.
  • Development: Enables teams to work on different services simultaneously, often with different technologies and frameworks.
  • Scaling: Allows for granular scaling, where individual services can be scaled independently based on their specific resource needs.

Advantages of Microservices

Independent Deployment

  • Each service can be deployed, updated, and scaled independently, reducing the risk of deployment failures and allowing for faster release cycles.

Technology Diversity

  • Teams can choose the best technology stack for each service based on its requirements, enabling the use of the latest and most suitable technologies.

Fault Isolation

  • Failures in one service do not necessarily affect other services, enhancing the overall resilience and reliability of the application.

Scalability

  • Services can be scaled independently, allowing for more efficient use of resources and cost-effective scaling.

Organizational Alignment

  • Microservices align well with agile and DevOps practices, allowing teams to be more autonomous and responsible for specific services.

Improved Maintainability

  • Smaller codebases are easier to understand, maintain, and refactor, leading to better code quality and reduced technical debt.

Disadvantages of Microservices

Complexity:

  • Managing multiple services, including their deployment, monitoring, and communication, introduces significant complexity compared to a monolithic application.

Distributed System Challenges

  • Issues such as network latency, message serialization, and handling partial failures need to be addressed.

Data Consistency

  • Maintaining data consistency across services can be challenging and often requires implementing complex patterns like eventual consistency and distributed transactions.

Increased Resource Consumption

  • Running multiple services often requires more resources, such as CPU, memory, and storage, compared to a monolithic application.

DevOps Overhead

  • Requires robust DevOps practices, including continuous integration, continuous deployment, containerization, and orchestration tools like Kubernetes.

Inter-Service Communication

  • Communication between services needs to be carefully managed to ensure efficient and reliable interactions, often requiring additional infrastructure like API gateways and service meshes.

Use Cases of Microservices

E-commerce Platforms

  • Individual services for user management, product catalog, inventory, payment processing, and order management.

Financial Systems

  • Separate services for account management, transaction processing, fraud detection, and reporting.

Social Media Applications

  • Distinct services for user profiles, posts, comments, likes, notifications, and messaging.

Healthcare Systems

  • Independent services for patient records, appointment scheduling, billing, and prescription management.

Conclusion

Microservices offer significant benefits in terms of flexibility, scalability, and maintainability, making them suitable for large, complex applications with high demands for agility and reliability. However, they also introduce considerable complexity and require sophisticated DevOps practices and infrastructure. The choice between monolithic and microservice architecture depends on the specific requirements, scale, and maturity of the development and operations teams within an organization.

core-go

GO libraries to develop micro services.

A typical micro service

When you zoom one micro service, the flow is as below A typical micro service

In the above image, you can see these libraries you need for a typical micro service

Database

Data Processing

Visit core-go/io, you can see rich data processing:

Message Queue

Please visit core-go/mq, Linked In article Standardize-7-Message-Queues.

Health Check

Please visit core-go/health and Microservice Health Check. We support databases, message queues, redis, http client:

health

Logging

Visit core-go/log and Middleware-Log-Tracing for more details.

Providers

Standardize API for logging, support 2 libraries:

Middleware Log Tracing

  • middleware: Log request and response at http middleware, allow to configure dynamic field names

Http Client Log Tracing

  • client: Log request and response at http client, allow to configure dynamic field names

Audit Log

  • Support for CRUD, search (not required in every application). Sample is at go-backoffice.

Caching

Memory Cache

Refer to MemoryCacheService for more details

  • Time To Live: automatically clean up the expired objects in the memory cache
  • Maximum size: When the memory exceeds the max size (which is configurable), it automatically remove the oldest object.

Redis

The library is here Redis. Support 2 libraries:

Validator

Check required, email, url, min, max, country code, phone number, regular expression...

Search

Samples are go-admin, go-backoffice and go-location

  • Generate the model by URL
  • Paging
  • Sort

Build a dynamic query for these providers

  • SQL
  • Mongo
  • Dynamodb
  • Firestore
  • Elasticsearch

Email

Storage

Authentication

Please visit Authentication, we support:

  • Support to log in by user name/password
  • Login by LDAP (both server side and client slide)
  • Login by Google, Facebook, Linkedin, Microsoft, Amazon, Dropbox
  • Support any database design (SQL, Mongo, Firestore, Cassandra)

Authorization

Please visit security: Sample is go-admin

  • Identity and Access Management: Authorization at middleware, support http (mux, chi), gin, echo
    • Support any database design (SQL, Mongo, Firestore, Cassandra)
  • Crypto
  • JWT

Others

sign up

sign up

sign up with password

  • sign up with password
  • verify account (without password)

sign up without password

  • sign up without password
  • verify account (require to input password)

authentication

Authentication

  • authenticator
  • ldap authenticator
  • 2 factor authentication

oauth2

oauth2

password

password

  • forgot password
  • change password (also support change password 2 factors)
  • reset password

Summary:

  • Libraries of core-go

Collection of libraries of core-go

Cross-cutting concerns

cross-cutting concerns

Hexagonal Architecture

Hexagonal Architecture

Low code

Components

Components

Commandline

export
  • input: database, project settings
  • output: metadata
generate
  • input: metadata, project templates
  • output: project (working application)

GUI

generator
  • GUI, include "export" and "generate"

Business View

Business View

Download

Output Samples

https://github.com/source-code-template

GO Layer Architecture Sample
nodejs Layer Architecture Sample
nodejs Modular Sample
nodejs Simple Modular Sample

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published