Code Monkey home page Code Monkey logo

dependencyinjectionandservicelifetimes's Introduction

Service Lifetimes Projesi

Bu proje, bir API’de Controller’a 2 kez request göndererek yanıtları karşılaştırmayı amaçlayan basit bir uygulamadır. Proje, 3 farklı servis türü (transient, scoped, singleton) ve bir controller içerir.

Proje Açıklaması

Dependency Injection kullanıldığında, servislerin nasıl oluşturulduğu ve ömür döngüleri önemli rol oynar. Bu projede ingleton, Scoped ve Transient olmak üzere üç farklı servis ömür döngüsünü inceleyeceğiz.

Service Lifetimes projesi, bir API'nin farklı servis ömürleriyle nasıl davrandığını anlamak ve bu servislerin taleplere nasıl yanıt verdiğini karşılaştırmak için tasarlanmıştır. Projede, aynı API'ye 2 kere request gönderilir ve her request’in yanıtı karşılaştırılır. Bu sayede, farklı servis ömürleri (transient, scoped, singleton) arasındaki farklar gözlemlenebilir.

Nasıl Çalışır?

Proje, aşağıdaki bileşenleri içerir:

  • SingletonService: Uygulama bazlı tekil nesne oluşturulur. Tüm taleplere o nesneyi gönderir.
  • ScopedService: Her request başına bir nesne üretir ve o request pipeline'ında olam tüm isteklere o nesneyi gönderir.
  • TransientService: Her request'in her talebine karşılık bir nesne üretir ve gönderir.
  • ServiceController: API taleplerini yöneten ve servislerle iletişim kuran bir controller.
Screenshot 2023-07-16 at 19 00 25 Screenshot 2023-07-16 at 19 01 17

Proje başlatıldığında, ServiceController, API'ye 2 kez talep gönderirseniz elde edeceğiniz response’lar şu şekilde olur :

Response 1 : Screenshot 2023-07-16 at 17 44 48

Request 2 : Pasted Graphic

Kurulum

Projeyi klonlayın

  git clone https://github.com/Gamzeen/DependencyInjectionAndServiceLifetimes.git

Service Lifetimes Project

This project is a simple application that aims to compare the responses by sending two requests to a Controller in an API. The project includes three different types of services (transient, scoped, singleton) and a controller.

Project Description

When using Dependency Injection, the creation and lifecycle of services play an important role. In this project, we will examine three different service lifetimes: Singleton, Scoped, and Transient.

The Service Lifetimes project is designed to understand how an API behaves with different service lifetimes and to compare how these services respond to requests. In the project, two requests are sent to the same API, and the responses of each request are compared. This allows us to observe the differences between different service lifetimes (transient, scoped, singleton).

How Does It Work?

The project includes the following components:

SingletonService: Creates a singleton object on an application-wide basis. It sends that object to all requests. ScopedService: Creates an object per request and sends that object to all requests within the request pipeline. TransientService: Creates an object for each individual request and sends it. ServiceController: Manages API requests and communicates with the services.

Screenshot 2023-07-16 at 19 00 25 Screenshot 2023-07-16 at 19 01 17

When the project is launched, if you send two requests to the API, the responses you would obtain would be as follows:

Response 1 : Screenshot 2023-07-16 at 17 44 48

Request 2 : Pasted Graphic

Setup

Clone the project

  git clone https://github.com/Gamzeen/DependencyInjectionAndServiceLifetimes.git

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.