Code Monkey home page Code Monkey logo

go_object-pool_pattern's Introduction

Object Pool Pattern Demonstration in Go

Overview

This repository showcases the implementation of the Object Pool design pattern in Go. The project demonstrates how to manage a pool of reusable resources โ€” in this case, database connections โ€” efficiently. The primary focus is on optimizing resource allocation, minimizing the overhead of resource initialization, and managing resource lifecycle to enhance application performance.

Pattern Description

The Object Pool Pattern is used to manage a set of ready-to-use objects from a pool rather than allocating and freeing them individually. This is especially useful in applications where the cost of initializing a class instance is high, the rate of instantiation of a class is high, and the number of instantiations in use at any one time is low. In this project, the pattern is implemented to manage database connections, ensuring that connections are reused efficiently and that the pool dynamically adjusts to load, improving overall application throughput.

Project Structure

  • cmd/: Contains the application entry point (main.go), demonstrating the use of the Object Pool pattern to manage database connections.
  • pkg/
    • pool/: Implements the connection pool, managing the lifecycle and availability of database connections.
  • internal/
    • database/: Contains the Connection class definition which represents individual database connections.

Getting Started

Prerequisites

Ensure you have Go installed on your system. You can download it from Go's official site.

Installation

Clone this repository to your local machine:

git clone https://github.com/arthurfp/Go_Object_Pool_Pattern.git
cd Go_Object_Pool_Pattern

Running the Application

To run the application, execute:

go run cmd/main.go

Running the Tests

To execute the tests and verify the functionality:

go test ./...

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues to discuss proposed changes or enhancements.

Author

Arthur Ferreira - github.com/arthurfp

go_object-pool_pattern's People

Contributors

arthurfp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.