<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mustafa Can Bildiren on Medium]]></title>
        <description><![CDATA[Stories by Mustafa Can Bildiren on Medium]]></description>
        <link>https://medium.com/@mcanbildiren?source=rss-e14a26fa0fc1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pbrl0EahcfC4TlrN6BxVFA.jpeg</url>
            <title>Stories by Mustafa Can Bildiren on Medium</title>
            <link>https://medium.com/@mcanbildiren?source=rss-e14a26fa0fc1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:10:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mcanbildiren/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Orchestration in SAGA Design Pattern]]></title>
            <link>https://medium.com/@mcanbildiren/orchestration-in-saga-design-pattern-7747af73f619?source=rss-e14a26fa0fc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7747af73f619</guid>
            <dc:creator><![CDATA[Mustafa Can Bildiren]]></dc:creator>
            <pubDate>Tue, 31 Dec 2024 12:42:56 GMT</pubDate>
            <atom:updated>2024-12-31T12:42:56.669Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern software development, distributed systems have become more common. These systems often require transactions that send requests to multiple services, making it challenging to provide data consistency.</p><p>Transaction here means that a single operation from start to end. For example in a banking application, if we want to transfer money, we first send a request to transfer service to send money. After that we need to update the user wallet balance. In this case whole process is called one single transaction and it should either be failed or succeed. So managing these steps is the important part for data consistency.</p><p>The <strong>Saga Design Pattern</strong> provides a robust solution to manage distributed transactions effectively.</p><p>In this paper we will focus on orchestration-based execution strategies, its architecture, implementation strategies, and practical use cases.</p><h3>What is the Saga Design Pattern?</h3><p>The <strong>Saga Design Pattern</strong> is a mechanism for handling distributed transactions across multiple micro-services. Instead of using a two-phase commit (2PC) protocol, which is complex and often infeasible in distributed systems, Sagas break down a transaction into a sequence of smaller, independent steps. Each step (or transaction) has a corresponding compensating action to undo the operation if something goes wrong.</p><h3>Key Components of Saga</h3><ol><li><strong>Steps (Transactions):</strong> Each step performs a specific action as part of the overall transaction.</li><li><strong>Compensating Transactions:</strong> Actions that roll back or undo changes if a failure occurs.</li><li><strong>Orchestrator:</strong> A centralized mechanism to coordinate the sequence of steps.</li></ol><h3>Orchestration-Based Saga</h3><p>In an <strong>orchestration-based saga</strong>, a centralized orchestrator manages and coordinates all steps involved in the transaction. The orchestrator tracks the progress of each step, triggers subsequent steps, and invokes compensating actions when failures occur.</p><h4>Key Features:</h4><ol><li><strong>Centralized Control:</strong> The orchestrator explicitly manages the flow of transactions, providing better control and visibility.</li><li><strong>Error Handling:</strong> Compensating transactions are defined and executed directly by the orchestrator in case of failures.</li><li><strong>State Management:</strong> The orchestrator maintains the state of the transaction, ensuring consistency.</li></ol><h4>Workflow Example:</h4><p>Consider an e-commerce application where an order process involves:</p><ol><li><strong>Order Service</strong> — Place an order.</li><li><strong>Payment Service</strong> — Process the payment.</li><li><strong>Inventory Service</strong> — Reserve items.</li><li><strong>Shipping Service</strong> — Schedule delivery.</li></ol><p><strong>Orchestrated Saga Example:</strong></p><ul><li>The Order Service acts as the orchestrator.</li><li>It initiates the payment step and waits for success.</li><li>If the payment fails, it triggers a compensating action to cancel the order.</li><li>Once payment succeeds, it proceeds to reserve inventory and finally schedules shipping.</li></ul><pre>public enum OrderState<br>{<br>    Created,<br>    PaymentProcessing,<br>    InventoryReserved,<br>    Shipped,<br>    Cancelled<br>}<br><br>public enum OrderEvent<br>{<br>    ProcessPayment,<br>    ReserveInventory,<br>    ShipOrder,<br>    CancelOrder<br>}<br><br>public class OrderStateMachine<br>{<br>    private OrderState _currentState;<br>    private Dictionary&lt;(OrderState, OrderEvent), OrderState&gt; _transitions;<br><br>    public OrderStateMachine()<br>    {<br>        _currentState = OrderState.Created;<br>        _transitions = new Dictionary&lt;(OrderState, OrderEvent), OrderState&gt;<br>        {<br>            { (OrderState.Created, OrderEvent.ProcessPayment), OrderState.PaymentProcessing },<br>            { (OrderState.PaymentProcessing, OrderEvent.ReserveInventory), OrderState.InventoryReserved },<br>            { (OrderState.InventoryReserved, OrderEvent.ShipOrder), OrderState.Shipped },<br>            { (OrderState.Created, OrderEvent.CancelOrder), OrderState.Cancelled },<br>            { (OrderState.PaymentProcessing, OrderEvent.CancelOrder), OrderState.Cancelled },<br>            { (OrderState.InventoryReserved, OrderEvent.CancelOrder), OrderState.Cancelled }<br>        };<br>    }<br><br>    public OrderState CurrentState =&gt; _currentState;<br><br>    public bool ProcessEvent(OrderEvent orderEvent)<br>    {<br>        if (_transitions.TryGetValue((_currentState, orderEvent), out var newState))<br>        {<br>            _currentState = newState;<br>            Console.WriteLine($&quot;Transitioned to state: {_currentState}&quot;);<br>            return true;<br>        }<br>        else<br>        {<br>            Console.WriteLine($&quot;Invalid transition from {_currentState} using event {orderEvent}&quot;);<br>            return false;<br>        }<br>    }<br>}</pre><pre>public class OrderWorker<br>{<br>    private readonly OrderStateMachine _stateMachine = new OrderStateMachine();<br><br>    public void ProcessOrder()<br>    {<br>        Console.WriteLine(&quot;Starting order process...&quot;);<br><br>        if (!_stateMachine.ProcessEvent(OrderEvent.ProcessPayment)) return;<br>        if (!_stateMachine.ProcessEvent(OrderEvent.ReserveInventory)) return;<br>        if (!_stateMachine.ProcessEvent(OrderEvent.ShipOrder)) return;<br><br>        Console.WriteLine(&quot;Order process completed successfully.&quot;);<br>    }<br>}<br><br>class Program<br>{<br>    static void Main(string[] args)<br>    {<br>        OrderWorker worker = new OrderWorker();<br>        worker.ProcessOrder();<br>    }<br>}</pre><h3>Advantages of Orchestration</h3><ol><li><strong>Resilience:</strong> Supports fault tolerance through compensating transactions.</li><li><strong>Centralized Monitoring:</strong> Easier to monitor and debug due to centralized control.</li><li><strong>Consistency:</strong> Ensures transactional consistency through explicit coordination.</li></ol><h3>Challenges and Considerations</h3><ol><li><strong>Orchestrator Overhead:</strong> The centralized component may become a bottleneck as the number of transactions increases.</li><li><strong>Error Propagation:</strong> Requires careful handling of errors to avoid cascading failures.</li><li><strong>Scalability:</strong> Scaling the orchestrator may require additional design considerations to handle high loads.</li></ol><h3>Conclusion</h3><p>The <strong>Saga Design Pattern</strong>, particularly the <strong>orchestration-based approach</strong>, is a powerful method for managing distributed transactions in micro-services-based architectures. It provides flexibility, scalability, and resilience while ensuring consistency through compensating actions. However, implementing it effectively requires careful planning, robust state management, and strong monitoring tools.</p><p>By leveraging the orchestration model, modern systems can achieve reliable and distributed transaction management, enabling seamless operations in complex architectures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7747af73f619" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Domain-Driven Design (DDD) in .NET Applications]]></title>
            <link>https://medium.com/@mcanbildiren/domain-driven-design-ddd-in-net-applications-50f90c453a7f?source=rss-e14a26fa0fc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/50f90c453a7f</guid>
            <dc:creator><![CDATA[Mustafa Can Bildiren]]></dc:creator>
            <pubDate>Sun, 30 Jun 2024 18:37:01 GMT</pubDate>
            <atom:updated>2024-06-30T18:37:01.603Z</atom:updated>
            <content:encoded><![CDATA[<h3>Domain-Driven Design (DDD) in .NET Applications</h3><p>In the landscape of software development, Domain-Driven Design (DDD) emerges as a philosophy aimed at managing complexities inherent in enterprise applications. This approach prioritizes a comprehensive understanding of the domain, or business context, in which the application operates, aligning the software development closely with business needs. For .NET developers, DDD offers a systematic way to craft software that is deeply interconnected with underlying business models, thereby increasing both utility and maintainability.</p><p><strong>What is Domain-Driven Design?</strong></p><p>DDD focuses on the core domain and domain logic of an application, basing its development on the complex needs and core functionalities required by business strategies. It involves creating a conceptual model that encapsulates the business domain, ensuring the software is intricately aligned with business activities and terms.</p><p>In a .NET context, this means structuring the project to mirror real-world business scenarios, enabling software that is intuitive to evolve and maintain as the domain itself evolves. DDD’s relevance grows with the complexity of the business and its processes, making it especially useful in scenarios where the business logic is intricate and heavily layered.</p><p><strong>Key Components of DDD</strong></p><p>To effectively implement DDD in .NET applications, several fundamental building blocks are utilized:</p><ul><li><strong>Entities</strong>: These are objects that have a distinct identity that runs through the system. For example, a Customer or Order entity in an e-commerce system uniquely identifies users and purchases.</li><li><strong>Value Objects</strong>: These objects do not have an identity and are immutable; they describe characteristics of things. For example, a Money object could represent an amount and currency but is defined only by its value.</li><li><strong>Aggregates</strong>: An aggregate is a collection of entities and value objects grouped together as a single unit for data changes, managed by aggregate roots. For instance, an Order aggregate might contain OrderItems and payment details, with the Order entity acting as the root.</li><li><strong>Repositories</strong>: These manage the retrieval and storage of aggregates from a database, ensuring the domain model does not deal directly with data access, thus staying agnostic of the persistence layer.</li><li><strong>Domain Services</strong>: These encapsulate business logic that doesn’t naturally fit within a single entity or value object and are typically stateless.</li><li><strong>Domain Events</strong>: These are significant events within the domain that the domain experts care about and may trigger side effects within the application.</li></ul><p><strong>Benefits of DDD in .NET</strong></p><p>The adoption of DDD in .NET applications offers numerous advantages:</p><ul><li><strong>Enhanced Communication</strong>: Utilizing the ubiquitous language of the domain promotes better communication between developers and non-developers, ensuring everyone has a clear understanding of the project goals and functionalities.</li><li><strong>Maintainability</strong>: Aligning the software structure with the business model helps simplify maintenance and future developments since changes in the business can be directly mapped to the software modules.</li><li><strong>Flexibility and Scalability</strong>: By separating concerns effectively, DDD facilitates flexible and scalable software architectures that can evolve as requirements grow or change without significant disruptions.</li></ul><p><strong>Challenges and Considerations</strong></p><p>While DDD presents many benefits, it also comes with challenges, particularly in its implementation:</p><ul><li><strong>Complexity in Design</strong>: Building a domain model can introduce additional complexity, especially in the initial phases of design and development.</li><li><strong>Increased Effort for Initial Setup</strong>: DDD requires thorough upfront analysis of the domain, which can lead to greater initial effort and a steeper learning curve.</li></ul><p><strong>Implementing DDD with .NET</strong></p><p>In practice, implementing DDD in .NET might involve a series of steps and considerations:</p><ol><li><strong>Domain Model Creation</strong>: Begin by crafting a robust domain model that encapsulates the business requirements. This involves identifying entities, value objects, aggregates, and bounded contexts.</li><li><strong>Use of Entity Framework</strong>: Leverage Entity Framework for ORM capabilities to handle data persistence. EF can map aggregates to database tables and manage complex data retrieval and persistence operations efficiently.</li><li><strong>Architectural Setup</strong>: Structure the application using layers (e.g., presentation, application, domain, infrastructure) to isolate domain logic from other concerns like UI and data access.</li><li><strong>Domain Services and Repositories</strong>: Implement services and repositories to encapsulate business rules and data access logic, ensuring they remain distinct from the domain model and other application layers.</li></ol><p><strong>Examples in a .NET Scenario</strong></p><p>Consider an e-commerce application designed using DDD principles:</p><ul><li><strong>Product Management</strong>: A Product aggregate could include entities like ProductDetail, Price, and Review. This aggregate ensures all product-related operations are localized, simplifying transactions like price updates or reviews management.</li><li><strong>Order Processing</strong>: The Order aggregate includes OrderItems, PaymentDetails, and a ShippingAddress. The order process is encapsulated within this aggregate, which handles everything from order placement to payment processing.</li></ul><p><strong>Conclusion</strong></p><p>Adopting DDD in .NET applications facilitates the creation of software that is more aligned with business requirements, easier to maintain, and better structured for future growth. While it requires a significant upfront investment in understanding the domain and setting up the architecture, the long-term benefits of enhanced communication, maintainability, and scalability make it a compelling choice for complex enterprise applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50f90c453a7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real-Time Web Applications Using SignalR]]></title>
            <link>https://medium.com/@mcanbildiren/real-time-web-applications-using-signalr-9371c00e888b?source=rss-e14a26fa0fc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9371c00e888b</guid>
            <dc:creator><![CDATA[Mustafa Can Bildiren]]></dc:creator>
            <pubDate>Sun, 30 Jun 2024 18:36:26 GMT</pubDate>
            <atom:updated>2024-06-30T18:36:26.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0JIhHXzkzEuGwe7IT0P9LQ.png" /></figure><p>Real-time functionality in web applications has become a necessity in today’s fast-paced digital environment, where instant communication and updates are expected. ASP.NET Core SignalR is a library designed to simplify the addition of real-time web functionality to applications, enabling server-side code to instantly push content to clients. In this article, we explore how SignalR can be utilized to build real-time web applications, focusing on its architecture, implementation strategies.</p><p><strong>Understanding SignalR</strong></p><p>SignalR is part of the ASP.NET Core framework, which facilitates adding real-time web functionalities such as live chat systems, real-time notifications, and interactive gaming interfaces to any web application. SignalR abstracts the complexity of handling connections, allowing developers to focus on core functionality rather than the details of connection management.</p><p><strong>Key Features of SignalR:</strong></p><ul><li><strong>Real-time HTTP-based communication</strong> using WebSockets as the primary transport, but automatically falling back to older techniques (like server-sent events and long polling) where necessary.</li><li><strong>Automatic reconnection</strong> capability, which is crucial for maintaining a stable user experience despite potential network instability.</li><li><strong>Scale-out support</strong> through backplanes like Azure SignalR Service, which is essential for applications requiring high availability and performance across multiple servers.</li></ul><p><strong>Core Components of SignalR</strong></p><ol><li><strong>Hubs</strong>: At the heart of SignalR is the concept of “hubs,” which are classes that serve as the main coordination point between clients and the server. Hubs allow clients and servers to call methods on each other directly.</li><li><strong>Connections</strong>: SignalR manages connections automatically, providing a persistent connection between the client and the server.</li><li><strong>Transports</strong>: SignalR supports multiple techniques for real-time communication. WebSockets are preferred for their low latency and full-duplex communication capabilities, but SignalR can also use server-sent events, long polling, and others as fallbacks.</li></ol><p><strong>Implementing SignalR in ASP.NET Core</strong></p><p>The implementation of SignalR in a web application involves several critical steps:</p><ol><li><strong>Setup and Configuration</strong>: First, SignalR is added to an ASP.NET Core project through NuGet packages. Developers then configure the middleware in the Startup.cs file to integrate SignalR into the app’s request processing pipeline.</li><li><strong>Creating Hubs</strong>: Developers define hubs by inheriting from the Hub class. Hubs facilitate client-server interaction, where methods defined in hubs can be called from the client side and vice versa.</li><li><strong>Client-Side Implementation</strong>: On the client side, JavaScript libraries provided by SignalR are used to establish a connection to the server hub. This allows the client to send and receive messages and updates in real-time.</li></ol><p><strong>Use Cases and Example</strong></p><p>We can use SignalR for sending and receiving real time notifications. For example in a messaging application.</p><ol><li>First step to implement SignalR is to install Microsoft.AspNetCore.SignalR package.</li></ol><pre>Install-Package Microsoft.AspNetCore.SignalR</pre><p>2. After that we can create a hub class</p><pre>using Microsoft.AspNetCore.SignalR;<br><br>namespace SignalRExample.Hubs;<br><br>public class NotificationHub : Hub<br>{<br>    public async Task SendNotification(string message)<br>    {<br>        await Clients.All.SendAsync(&quot;ReceiveNotification&quot;, message);<br>    }<br>}</pre><p>3. We also need to configure SignalR in Program.cs</p><pre>---------------------------------------------------------------------------<br>builder.Services.AddSignalR();<br>---------------------------------------------------------------------------<br>app.UseEndpoints(endpoints =&gt;<br>{<br>  endpoints.MapControllerRoute(<br>    name: &quot;default&quot;,<br>    pattern: &quot;{controller=Home}/{action=Index}/{id?}&quot;);<br>  endpoints.MapHub&lt;NotificationHub&gt;(&quot;/notificationHub&quot;);<br>});<br>---------------------------------------------------------------------------</pre><p>4. Finally we can create a basic view to send notifications and list them.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Notifications&lt;/title&gt;<br>    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/5.0.10/signalr.min.js&quot;&gt;&lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;div&gt;<br>    &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot; style=&quot;margin-bottom: 30px&quot; onclick=&quot;sendNotification()&quot;&gt;Send Notification&lt;/button&gt;<br>    &lt;button type=&quot;button&quot; class=&quot;btn btn-danger&quot; style=&quot;margin-bottom: 30px; margin-left: 20px&quot; onclick=&quot;deleteNotifications()&quot;&gt;Delete Notifications&lt;/button&gt;<br>&lt;/div&gt;<br>&lt;div&gt;<br>    &lt;div class=&quot;card&quot; style=&quot;width: 18rem;&quot;&gt;<br>        &lt;div class=&quot;card-header&quot;&gt;<br>            Notifications<br>        &lt;/div&gt;<br>        &lt;ul id=&quot;notificationsList&quot; class=&quot;list-group list-group-flush&quot;&gt;<br>        &lt;/ul&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;<br><br>&lt;script&gt;<br>    const connection = new signalR.HubConnectionBuilder()<br>        .withUrl(&quot;/notificationHub&quot;)<br>        .build();<br><br>    connection.on(&quot;ReceiveNotification&quot;, function (message) {<br>        const li = document.createElement(&quot;li&quot;);<br>        li.classList.add(&quot;list-group-item&quot;);<br>        li.textContent = message;<br>        document.getElementById(&quot;notificationsList&quot;).appendChild(li);<br>    });<br><br>    connection.start().catch(function (err) {<br>        return console.error(err.toString());<br>    });<br><br>    function sendNotification() {<br>        const message = &quot;New notification at &quot; + new Date().toLocaleTimeString();<br>        connection.invoke(&quot;SendNotification&quot;, message).catch(function (err) {<br>            return console.error(err.toString());<br>        });<br>    }<br><br>    function deleteNotifications() {<br>        const notificationsList = document.getElementById(&quot;notificationsList&quot;);<br>        notificationsList.innerHTML = &#39;&#39;;<br>    }<br>&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sGC4AZzc2vkGTzInT703Rw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*a4d1bLyfhVfj1IXK-7Twzg.png" /></figure><p><strong>Conclusion</strong></p><p>Building real-time web applications with ASP.NET Core SignalR provides a robust framework for developers to add interactive, real-time features to their applications. By understanding and implementing SignalR’s core components, developers can create responsive and engaging user experiences that meet modern web standards. As real-time interactions become increasingly important in web applications, mastering technologies like SignalR is crucial for developers aiming to stand out in the competitive landscape of digital services.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9371c00e888b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is an API Proxy?]]></title>
            <link>https://medium.com/@mcanbildiren/what-is-an-api-proxy-a550fabada60?source=rss-e14a26fa0fc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a550fabada60</guid>
            <dc:creator><![CDATA[Mustafa Can Bildiren]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 12:13:06 GMT</pubDate>
            <atom:updated>2024-06-25T12:13:06.756Z</atom:updated>
            <content:encoded><![CDATA[<p>An API proxy acts as a bridge between clients and an API, serving as a centralized gateway. It improves the API with additional functionalities like security, caching, and rate limiting, all without requiring changes to the API itself.</p><p>This versatile tool can also route requests from various users or paths to different backend services tailored to their specific requirements. Simultaneously, it handles tasks such as authentication and traffic management.</p><h3>How do They Work?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*maoNlLe7mvCd3yfvmacrMw.png" /></figure><h4>Step 1</h4><p>The client submits a request to the API proxy, including details such as the endpoint URL, headers containing essential host information, the HTTP method, and any additional parameters needed.</p><h4>Step 2</h4><p>The API proxy receives the request and applies security checks. After that, it forwards the request to the backend API by establishing a connection and transmitting the request over that connection.</p><h4>Step 3</h4><p>Upon receiving the request, the backend API processes it and sends a response back to the API proxy through the existing connection. The API proxy then receives and processes the response, which may include converting it into a client-compatible format if necessary.</p><h4>Step 4</h4><p>The API proxy then sends the response back to the client, which receives and processes it according to its requirements.</p><h3>API Proxy serves several purposes</h3><h3>Security</h3><p>API proxies play a crucial role in ensuring the security of backend services.</p><h4><strong>Authentication and Authorization</strong></h4><p>Proxies can authenticate incoming requests, ensuring that only authorized clients can access the backend services. This can be achieved by using API keys, OAuth tokens, or other authentication tools.</p><h4><strong>Encryption</strong></h4><p>They can enforce SSL/TLS encryption between clients and the proxy, as well as between the proxy and backend services, to secure data transmission against hackers.</p><h4><strong>Firewall and Filtering</strong></h4><p>Proxies can act as a firewall, filtering out malicious requests or requests that violate security policies before they reach the backend services.</p><h3>Monitoring and Analytics</h3><p><strong>Traffic Monitoring</strong></p><p>They can log detailed information about incoming requests, including timestamps, endpoints, and client IPs. This data is useful for monitoring overall API usage and identifying potential issues.</p><h4><strong>Performance Metrics</strong></h4><p>Proxies can measure response times and throughput, helping to identify bottlenecks and optimize backend service performance.</p><h4><strong>Usage Analytics</strong></h4><p>They track usage patterns, such as which endpoints are most frequently accessed or which clients are making the most requests. This information is useful for capacity planning and resource allocation.</p><h3>Rate Limiting</h3><p><strong>Throttling</strong></p><p>Proxies can implement rate limits on API requests, managing how many requests a client can make over a given time period. This prevents one client from using all of the resources and ensures that the backend services remain responsive for all users.</p><h3>Transformation and Aggregation</h3><p>Proxies can modify API requests and responses to meet specific requirements.</p><h4><strong>Data Format Conversion</strong></h4><p>They can translate between different data formats (e.g., JSON to XML) to accommodate different client expectations or backend capabilities.</p><h4><strong>Response Aggregation</strong></h4><p>They can combine data from multiple backend services into a single response, reducing the number of round-trips required for clients to retrieve information.</p><h3>Routing</h3><p>Proxies provide flexibility in directing requests to appropriate backend services.</p><h4><strong>Load Balancing</strong></h4><p>They can distribute incoming requests across multiple instances of a backend service to optimize resource utilization and ensure high availability.</p><h4><strong>Dynamic Routing</strong></h4><p>Based on criteria such as geographical location or the type of request, proxies can route requests to different backend services.</p><h3>Benefits of Using API Proxies</h3><h4><strong>Centralized Control</strong></h4><p>Proxies provide a centralized point for managing and monitoring API traffic, simplifying administration and ensuring consistent policies across services.</p><h4><strong>Enhanced Security</strong></h4><p>By implementing security measures and shielding backend services from direct exposure, proxies reduce the attack surface and improve overall system security.</p><h4><strong>Scalability</strong></h4><p>They facilitate scaling by offloading tasks such as authentication, rate limiting, and traffic management from backend services, allowing them to focus on core functionality.</p><h3>Types of API Proxies</h3><h4><strong>Reverse Proxy</strong></h4><p>Handles incoming requests from clients and forwards them to backend servers. It has features such as load balancing, SSL termination, caching.</p><h4><strong>API Gateway</strong></h4><p>Centralizes API management, acting as a single entry point for clients. It’s main features are security (authentication, authorization), routing, rate limiting and monitoring.</p><h4><strong>Forward Proxy</strong></h4><p>Intercepts outgoing client requests and forwards them to the internet. Mainly used for anonymity, content filtering, caching.</p><h4><strong>Transparent Proxy</strong></h4><p>Intercepts traffic without client-side configuration, providing visibility and control. Features; invisible to clients, content filtering, caching.</p><h3>Possible Challenges of Using API Proxies</h3><h4><strong>Latency</strong>:</h4><p>Introducing an API proxy can add latency to API requests due to the additional network hop and processing time required by the proxy.</p><h4><strong>Single Point of Failure</strong></h4><p>If the API proxy fails, it can disrupt all API traffic passing through it, affecting service availability.</p><h4><strong>Complexity</strong></h4><p>Managing and configuring an API proxy can be complex, especially as the number of APIs and traffic volume increases.</p><h4><strong>Security Risks</strong></h4><p>Improperly configured proxies can introduce security vulnerabilities, such as misconfigured access controls or insufficient encryption.</p><h4><strong>Performance Bottlenecks</strong></h4><p>Incorrect proxy configuration or overload can lead to performance bottlenecks, affecting overall system responsiveness.</p><h4><strong>Dependency on Third-Party Tools</strong></h4><p>Projects relying on third-party API proxy solutions may face limitations or dependencies on support and updates.</p><h4><strong>Monitoring and Debugging</strong></h4><p>Troubleshooting issues within an API proxy setup can be challenging, requiring monitoring and diagnostic tools.</p><h4><strong>Cost</strong></h4><p>Depending on the scale and features required, deploying and maintaining an API proxy solution can incur significant costs in terms of hardware, software, and operational overhead.</p><h3>Conclusion</h3><p>While API proxies provide essential benefits such as enhanced security, centralized management, and improved performance through features like caching and load balancing, they also introduce challenges that projects could have. These challenges include potential latency issues, single points of failure, increased complexity in configuration and management, security risks if not properly secured, and considerations of performance optimization and cost management. By carefully assessing these factors and implementing monitoring and management practices, projects can effectively use API proxies to streamline API interactions while mitigating associated risks and maximizing operational efficiency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a550fabada60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asenkron Programlama]]></title>
            <link>https://medium.com/@mcanbildiren/asenkron-programlama-c0cb2e282923?source=rss-e14a26fa0fc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0cb2e282923</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mustafa Can Bildiren]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 11:38:25 GMT</pubDate>
            <atom:updated>2023-09-25T11:38:25.885Z</atom:updated>
            <content:encoded><![CDATA[<h3>Senkron ve Asenkron Ne Demektir?</h3><p>Kelime anlamı olarak senkron eşzamanlı, asenkron da bunun tersi demektir.</p><p>Yazılan kod asenkron olarak belirtilmezse sırayla, yukarıdan aşağıya doğru olucak şekilde çalışır. Yapılan bir işlem, hesaplama bitmeden diğerine geçilmez.</p><p>Asenkron programlamada kod istenilen sırada çalıştırılabilir. Mesela en sonda yazılan bir fonksiyonun en başta çalışması sağlanabilir.</p><pre>console.log(&quot;1. Satır&quot;);<br>console.log(&quot;2. Satır&quot;);<br>console.log(&quot;3. Satır&quot;);</pre><p>Yukarıdaki kod örneğinde çıktı</p><pre>1. Satır<br>2. Satır<br>3. Satır</pre><p>şeklinde olucaktır. Çünkü kod derlenirken her satır sırayla çalışacaktır.</p><p>Asenkron olan setTimeout metodunu kullanarak bir kod yazıcak olursak;</p><pre>console.log(&#39;1. Satır&#39;);<br><br>setTimeout(function wait() {<br>  console.log(&#39;2. Satır&#39;);<br>}, 2000)<br><br>console.log(&#39;3. Satır);</pre><p>bu kodun çıktısı;</p><pre>1. Satır<br>3. Satır<br>2. Satır</pre><p>şeklinde olur. Buradaki setTimeout metodu asenkron olarak çalıştığından sistem bu kodu gördüğü zaman bitmesini beklemeden bir alt satıra geçecektir.</p><h3>C# Async/Await</h3><pre>public static async Task Main(string[] args)<br> {<br>  UzunSurenHesaplama();<br>  KısaSurenIs();<br>  <br>  Console.ReadKey();<br> }<br><br> public static async void UzunSurenHesaplama()<br> {<br>  Console.WriteLine(&quot;Uzun Süren Hesaplama Başlatıldı!&quot;);<br>  await Task.Delay(4000); // sistemi 4 saniye bekletir<br>  Console.WriteLine(&quot;Uzun Süren Hesaplama Tamamlandı!&quot;);<br> }<br><br> static void KısaSurenIs()<br> {<br>  Console.WriteLine(&quot;Kısa Süren İş Başlatıldı!&quot;);<br>  Console.WriteLine(&quot;Kısa Süren iş Tamamlandı!&quot;);<br> }</pre><p>Çıktı:</p><pre>Uzun Süren Hesaplama Başlatıldı!<br>Kısa Süren İş Başlatıldı!<br>Kısa Süren iş Tamamlandı!<br>Uzun Süren Hesaplama Tamamlandı!</pre><p>Yukarıdaki örnekte kullanılan async kelimesi metodun asenkron olarak çalışacağını belirtmek için kullanılır. Asenkron metodlar kullanabilmek için sadece metodun kendisini değil, Main metodunu da async olarak belirleyip, dönüş tipini task olarak belirlememiz gerekmektedir. UzunSurenHesaplama metodu async olarak belirtildiği için asenkron çalışır. await Task.Delay(4000) metodu thread’i 4 saniye bekletir.</p><p>Uygulama başlatıldığında Main metodu ana thread içinde çalışmaya başlar. async UzunSurenHesaplama metoduna geldiği zaman ayrı bir thread başlatıp bu metodu onun üzerinde çalıştırır. Bu sürede ana thread çalışmaya devam ettiği için bir alt satırdan devam eder ve KısaSurenIs metodu çalışır.</p><p>Await kelimesi asenkron metodun işini yapana kadar thread’in bekletilmesini sağlar. Task.Delay(4000) metodunda await kullandığımız için yeni oluşturulan thread 4 saniye geçmesini bekledikten sonra bir sonraki satıra geçip çalışmaya devam edecektir.</p><pre>static async Task Main(string[] args)<br>{<br>    Task&lt;int&gt; sonuc = UzunSurenHesaplama();<br><br>    KısaSurenIs();<br><br>    var deger = await sonuc;<br><br>    Console.WriteLine(&quot;Sonuç: {0}&quot;, deger);<br><br>    Console.ReadKey();<br>}<br><br>static async Task&lt;int&gt; UzunSurenHesaplama()<br>{<br>    Console.WriteLine(&quot;Uzun Süren Hesaplama Başlatıldı!&quot;);<br><br>    await Task.Delay(4000);<br><br>    Console.WriteLine(&quot;Uzun Süren Hesaplama Tamamlandı!&quot;);<br><br>    return 10;<br>}<br><br>static void KısaSurenIs()<br>{<br>    Console.WriteLine(&quot;Kısa Süren İş Başlatıldı!&quot;);<br><br>    Console.WriteLine(&quot;Kısa Süren İş Tamamlandı!&quot;);<br>}</pre><p>Yukarıdaki örnekte diğerinden faklı olarak, asenkron olan metod bu sefer bir değer dönmektedir. Dönüş tipini Task&lt;int&gt; şeklinde belirtmemiz gerekmektedir.</p><p>Kodun çıktısı:</p><pre>Uzun Süren Hesaplama Başlatıldı!<br>Kısa Süren İş Başlatıldı!<br>Kısa Süren İş Tamamlandı!<br>Uzun Süren Hesaplama Tamamlandı!<br>Sonuç: 10</pre><p>var deger = await sonuc; satırında await kelimesinden dolayı ana thread durdurulur ve “sonuc” değişkeni içine değer gelene kadar beklenir. Değer geldikten sonra “deger” değişkeni içine int tipinde değer atanmış olur.</p><p>Asenkron bir metodun dönüş biçimi void, Task ya da Task&lt;TResult&gt; olmalıdır. Dönecek değerin tipi ise TResult yerine yazılarak belirtilebilir; örnek koddaki Task&lt;int&gt; gibi.</p><h3>Kaynaklar</h3><ul><li><a href="https://learn.microsoft.com/tr-tr/dotnet/csharp/asynchronous-programming/async-scenarios">Zaman uyumsuz programlama - C #</a></li><li><a href="https://www.geeksforgeeks.org/async-and-await-in-c-sharp/">Async and Await in C# - GeeksforGeeks</a></li><li><a href="https://www.tutorialsteacher.com/articles/asynchronous-programming-with-async-await-task-csharp">Asynchronous programming with async, await, Task in C#</a></li><li><a href="https://www.c-sharpcorner.com/article/async-and-await-in-c-sharp/">Async and Await in C#</a></li><li><a href="https://www.w3schools.com/jsref/met_win_settimeout.asp">W3Schools.com</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0cb2e282923" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hangfire Jobs]]></title>
            <link>https://medium.com/@mcanbildiren/hangfire-jobs-9d80cf8dcd2c?source=rss-e14a26fa0fc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d80cf8dcd2c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[hangfire]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mustafa Can Bildiren]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 11:37:57 GMT</pubDate>
            <atom:updated>2023-09-25T11:37:57.270Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>HangFire Nedir?</strong></h3><p>Hangfire, arka planda asenkron olarak çalışabilen işlerin yazılmasını sağlayan açık kaynaklı bir kütüphanedir. Oluşturulan bu işlerin yönetilmesi için kendi kullanıcı paneli vardır. Haftalık, günlük gibi farklı zamanlarda ya da sürekli çalışan işler yazılabilir.</p><p>Hangfire işlerini çalıştırabilmek için bir veritabanı kullanılması gerekmektedir. SQL Server, PostgreSQL, Redis, Mongo gibi farklı veritabanlarında çalışabilmektedir.</p><h3><strong>Avantajları</strong></h3><ul><li>Kullanımı kolaydır, kütüphanesi NuGet paket yöneticisi üzerinden yüklenip birkaç satır kod ile projeye dahil edilebilir.</li><li>Çalıştırılacak iş ile ilgili bilgilerin tamamı veritabanında tutulur, bu sayede tutarlılık ve güvenlik sağlanır.</li><li>Bir iş başarısız olduğunda kendiliğinden tekrar çalıştırılmasını sağlar.</li></ul><h3>Job Türleri</h3><ul><li><strong><em>Fire-and-forget:</em></strong> İş tanımlandıktan <strong>hemen sonra</strong> ve <strong>sadece bir kere</strong> çalışır.</li></ul><pre>var jobId = BackgroundJob.Enqueue(<br>    () =&gt; Console.WriteLine(&quot;Fire-and-forget!&quot;));</pre><ul><li><strong><em>Delayed:</em></strong> İş tanımlandığından <strong>belirli bir zaman geçtikten sonra</strong> ve yine <strong>sadece bir kere</strong> çalışır. Örnekte, 7 gün olarak belirlenen süre dolduğu zaman kod çalışacaktır.</li></ul><pre>var jobId = BackgroundJob.Schedule(<br>    () =&gt; Console.WriteLine(&quot;Delayed!&quot;),<br>    TimeSpan.FromDays(7));</pre><ul><li><strong><em>Recurring:</em></strong> <strong>Belirlenen zamanda tekrarlayacak</strong> şekilde çalışır. Örnekte Cron ile günlük olarak ayarlandığı için kod her gün aynı zamanda bir kere çalışacaktır.</li></ul><pre>RecurringJob.AddOrUpdate(<br>    &quot;myrecurringjob&quot;,<br>    () =&gt; Console.WriteLine(&quot;Recurring!&quot;),<br>    Cron.Daily);</pre><ul><li><strong><em>Continuations: </em>Başka bir işe bağlı olarak çalışır.</strong> jobId ile tanımlanan bir diğer arka plan işi tamamlandıktan hemen sonra çalışacaktır.</li></ul><pre>BackgroundJob.ContinueJobWith(<br>    jobId,<br>    () =&gt; Console.WriteLine(&quot;Continuation!&quot;));</pre><ul><li><strong><em>Batch:</em></strong> <strong>Birden fazla işin</strong> grup halinde çalıştığı işlerdir. İçerisindeki işler sırayla çalışacaktır. Batch HangFire PRO sürümüyle birlikte kullanılabilmektedir.</li></ul><pre>var batchId = Batch.StartNew(x =&gt;<br>{<br>    x.Enqueue(() =&gt; Console.WriteLine(&quot;Job 1&quot;));<br>    x.Enqueue(() =&gt; Console.WriteLine(&quot;Job 2&quot;));<br>});</pre><ul><li><strong><em>Background Process:</em></strong> <strong>Uygulama çalıştığı sürece</strong>, arka planda <strong>sürekli</strong> olarak çalışacak olan işlerdir. Örnekte uygulama çalıştığı sürece, her saatte bir istenilen kod çalışacaktır.</li></ul><pre>public class CleanTempDirectoryProcess : IBackgroundProcess<br>{<br>    public void Execute(BackgroundProcessContext context)<br>    {<br>        Directory.CleanUp(Directory.GetTempDirectory());<br>        context.Wait(TimeSpan.FromHours(1));<br>    }<br>}</pre><h3>HangFire Admin Paneli</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2M5yCEil_yonN0ZQCyscw.png" /><figcaption>Admin Paneli İşler Sekmesi</figcaption></figure><p>Admin panelinde işler sekmesinde projede yazılan işlerin tamamı görülebilir ve yönetilebilir.</p><p>Hemen çalışacak olan işleri sırasıyla görmenin yanı sıra belirli bir zaman aralığında çalışan işlerin de takibi yapılabilir.</p><p>HangFire’da başarısız olan işler kendiliğinden yeniden başlatılır. Bu işlerin takibi de görseldeki ekranlardan yapılabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I73hbFDgy1xlgD_CwdIn5g.png" /><figcaption>Başarısız Olan İşlerin Listesi</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tAyHdR5apTYmwuwHQ58P1g.png" /><figcaption>Tekrar Denenicek Olan İşler</figcaption></figure><p>Bu ekrandan hangi işin ne zaman tekrar çalıştırmayı deneneceği görüntülenebilir. Tekrar deneme sayısı 10 olarak belirlenmiştir fakat değiştirilebilir.</p><p><strong>Kaynaklar</strong></p><p><a href="https://www.hangfire.io/">Hangfire - Background Jobs for .NET and .NET Core</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d80cf8dcd2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON WEB TOKEN]]></title>
            <link>https://medium.com/@mcanbildiren/json-web-token-23890d9b5c20?source=rss-e14a26fa0fc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/23890d9b5c20</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[json-web-token]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Mustafa Can Bildiren]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 14:08:30 GMT</pubDate>
            <atom:updated>2023-03-27T14:08:30.232Z</atom:updated>
            <content:encoded><![CDATA[<h3>Nedir?</h3><p>JSON Web Token (JWT), JSON tipinde verilerin taşınmasını sağlayan, kullanıcı kimlik doğrulama için kullanılabilen bir standarttır(<a href="https://www.rfc-editor.org/rfc/rfc7519">RFC 7519</a>). Dijital olarak imzalandığından dolayı güvenlidir.</p><h3>Başlıca Avantajları</h3><ul><li>Token içerisindeki data, kullanım süresi gibi bilgiler token içerisinde tutulur, başka bir yere kaydedilmez.</li><li>JSON veri tipini kullanır.</li><li>Boyutu küçük olduğundan bir URL içerisinde, bir POST metodunun parametresi olarak ya da bir HTTP header’ı içerisinde rahatlıkla gönderilebilir.</li><li>Kimlik doğrulama işlemi sırasında isteği yapan kullanıcı hakkındaki tüm bilgiler token içerisinde mevcut olduğundan veri tabanına birden fazla sorgu yapılmamış olur.</li><li>Base64URL ile şifrelendiği için okumaya açıktır fakat değiştirilemez.</li><li>Mobilde kullanım için uygundur, cookie gereksinimi yoktur.</li></ul><h3>Kimlik doğrulama sırasında kullanım</h3><p>Kullanıcı bilgilerini doğru bir şekilde yazıp giriş yaptıktan sonra oluşturulan JWT, kullanıcının yaptığı her istekte kullanılır. Böylece kullanıcının erişebileceği yerler, bilgiler bu token üzerinden kontrol edilmiş olur. Bu token farklı domainler arasında da paylaşılabildiğinden tek sefer giriş yapılan sistemlerde kullanılabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*SP3nNiqWRsfsUsSrZ-O7RA.png" /><figcaption>Tokenin kimlik doğrulama kullanımının örnek diagramı</figcaption></figure><h3>Token yapısı</h3><p>JWT’ler 3 bölümden oluşurlar. Bu bölümler Base64URL ile şifrelendiği için okumaya açık fakat değiştirilmeye kapalıdır. Bölümler biribirinden nokta (.) ile ayrılır. Örnek bir token görüntüsü;</p><pre>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ik<br>NhbiBCaWxkaXJlbiIsImlhdCI6MTUxNjIzOTAyMn0.iwKTW1BsikkXZTluWhHnYCxx_L5Y-JtWV<br>N9McohpJoI</pre><p><strong><em>Header: </em></strong>Token türünü (<strong>typ</strong>) ve kullanılan hash algoritmasının (<strong>alg</strong>) tutulduğu alandır.</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;<br>}</pre><p><strong><em>Payload: </em></strong>Datanın tutulduğu bölümdür. Kullanıcı rolleri, isim, mail adresi gibi kullanıcı için gizli olmayan bilgiler tutulur. Değerler key-value çifleri olarak tutulutlar ve bunlara “claim” denir. <a href="https://www.rfc-editor.org/rfc/rfc7519#section-4.1">Önceden tanımlanmış claimler</a> kullanılabilir. Bunlardan bazıları; issuer (<strong>iss</strong>), expiration time (<strong>exp</strong>), subject (<strong>sub</strong>), audience (<strong>aud</strong>), issued at (<strong>iat</strong>).</p><pre>{<br>  &quot;sub&quot;: &quot;1234567890&quot;,<br>  &quot;name&quot;: &quot;Can Bildiren&quot;,<br>  &quot;iat&quot;: 1516239022<br>}</pre><p><strong><em>Signature</em></strong>: Tokenin güvenilir olduğunu ve değiştirilmediğinin anlaşıldığı bölümdür. Token kullanılmadan önce <em>signature</em> kısmı mutlaka kontrol edilmelidir. Header ve payload için kullanılan şifreleme yöntemini gösterir, ayrıca doğrulama için <em>secret key</em> tutar.</p><pre>HMACSHA256(<br>  base64UrlEncode(header) + &quot;.&quot; +<br>  base64UrlEncode(payload),<br>  <br>your-256-bit-secret<br><br>)</pre><h3>Kaynakça</h3><ul><li><a href="https://jwt.io/">JSON Web Tokens - jwt.io</a></li><li><a href="https://auth0.com/docs/secure/tokens/json-web-tokens">JSON Web Tokens - Auth0 Docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23890d9b5c20" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>