<?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 Ali UYGUR on Medium]]></title>
        <description><![CDATA[Stories by Ali UYGUR on Medium]]></description>
        <link>https://medium.com/@alioygur?source=rss-d0723f3d97ab------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*q7Cp5UHa9eSbVVscuS8mnw.jpeg</url>
            <title>Stories by Ali UYGUR on Medium</title>
            <link>https://medium.com/@alioygur?source=rss-d0723f3d97ab------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 21:25:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alioygur/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[Accelerate your “Time to Market” with Serverless]]></title>
            <link>https://medium.com/teknasyon-engineering/accelerate-your-time-to-market-with-serverless-9591afb5ec45?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/9591afb5ec45</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Thu, 08 Jun 2023 08:37:41 GMT</pubDate>
            <atom:updated>2023-06-08T08:37:41.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1nj_I5qIqPFMgAeUlxGhw.jpeg" /></figure><p>Time to market, bir ürünün veya hizmetin fikir aşamasından piyasaya sürüldüğü ana kadar geçen süreyi ifade eder. Buna aynı zamanda geliştirme aşaması da diyebiliriz.</p><p>Bu süreyi mümkün olduğunca hızlı tamamlayarak, hem daha az maliyetle hem de rakiplere karşı ciddi bir avantaj elde edebiliriz.</p><p>Bu süreci güvenli ve ölçeklenebilir bir şekilde kısaltmanın en etkili yollarından biri, kendi işimize odaklanıp bunun dışındaki ihtiyaçları hizmet olarak satın almaktır.</p><p>Tam da bu noktada, serverless ürünler kullanmak çok doğru bir tercih olabilir. Çünkü:</p><p>- Sadece kullandığınız kadar ödeme yaparsınız.<br>- Yönetim ve bakım gerektirmezler.<br>- Yüksek ölçeklenebilirler.</p><p>Hadi gelin, bu ürünlerden bazılarını inceleyelim.</p><h4>1. GCP Cloud Build</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gLalWId_F4epXyfe9ptimg.png" /></figure><p>Bir ürün geliştirmeye başlamadan önce takım için konforlu, güvenli ve hızlı bir geliştirme ortamı hazırlamak çok önemlidir. Bunu bir üretim bandı gibi düşünebilirsiniz.</p><p>Örneğin, bir repo oluşturdunuz, ilk geliştirmenizi yaptınız. Bu değişikliği merkezi reponuza gönderdiğiniz anda bir pipeline’ın çalışıp bu değişiklik üzerinden testleri çalıştırıp, build edip istediğiniz bir ortama deploy edilmesini istiyorsunuz.</p><p>GCP Cloud Build bu konudaki ihtiyacımızı karşılayabilecek serverless bir CI/CD pipeline çalıştırıcısıdır.</p><p><strong>Docker Compatible</strong></p><p>Cloud Build’de her step bir docker container olarak çalışır. Bu sayede istediğiniz herhangi bir docker imajını kullanabilirsiniz. Örneğin bir step’de nodejs, bir step’de python, bir step’de java, bir step’de go vs. gibi birçok farklı dil ve framework kullanabilirsiniz.</p><p><strong>Multiple configuration file</strong></p><p>Cloud Build’de isterseniz tek bir yaml dosyasında tüm pipeline’i tanımlayabilirsiniz. İsterseniz de her bir step için ayrı bir yaml dosyası oluşturabilirsiniz. Bu sayede pipeline’ınızı daha modüler bir şekilde tanımlayabilirsiniz.</p><p><strong>Invokes with repository events like “push to branch”, “push new tag”, “pull request” and Manuel, Pub/Sub and Webhook</strong></p><p>Cloud Build pipeline’ınızı manuel olarak çalıştırmanın yanında aşağıdaki gibi birçok farklı event’e göre de otomatik tetikleyebilirsiniz.</p><ul><li>Push to branch</li><li>Push new tag</li><li>Pull request</li><li>Pub/Sub</li><li>Webhook</li></ul><p>Cloud Build’in günlük 120 dakika ücretsiz kullanım hakkı vardır. Bu süreyi aşarsanız dakika başına $0.003 ödersiniz.</p><p><a href="https://cloud.google.com/build">https://cloud.google.com/build</a></p><h4>2. GCP Cloud Run</h4><p>Gelelim ikinci ürünümüze, GCP Cloud Run bir serverless container çalıştırıcısıdır; üretim bandımızdan ilk versiyonumuz çıktı, bu versiyonu Docker ile paketledik ve artık bu imajı Cloud Run’da çalıştırabiliriz.</p><p><strong>Any language, any library, any binary</strong></p><p>Cloud Run ile ilgili en güzel şeylerden biri de istediğiniz bir Docker imajını çalıştırabilirsiniz. Yani dil, framework, kütüphane, binary vs. gibi bir kısıtlamanız yok.</p><p><strong>Per-instance concurrency</strong></p><p>Cloud Run, her bir instance için bir concurrency limiti koymanıza izin verir. Bu sayede bir instance’ın aynı anda kaç request’i cevaplayabileceğini belirleyebilirsiniz. Default olarak bu değer 80&#39;dir. Bu değeri 1&#39;e çekerseniz Cloud Run sizin için her bir request için yeni bir instance oluşturur. Bu değer 1–1000 arasında olabilir.</p><p><strong>Fast autoscaling</strong></p><p>Cloud Run servisinize gelen request sayısına göre otomatik olarak instance’larınızı default kotada 0–1000 arasında ölçekleyebilir. Eğer 15 dakika boyunca hiç request gelmezse instance’larınız 0&#39;a kadar inebilir. Bu sayede gereksiz yere instance’larınızın çalışmasını engelleyebilirsiniz.</p><p>Aklınıza hemen “Cold Start” derdi geldi değil mi? Dert etmeyin isterseniz minimum instance sayısını 1 olarak belirleyebilirsiniz. Bu sayede instance’larınız hiçbir zaman 0&#39;a inmez. Şimdi de aklınıza gereksiz maliyet geldi değil mi? Size bir güzel haber daha: Google idle durumundaki instancelar 10 kat daha ucuz. Yani hazırda bekleyen instance’lar herhangi bir kaynak tüketmiyorsa CPU, RAM vs. gibi kaynaklarınızı 10 kat daha az ödersiniz.</p><p><strong>HTTPS URLs</strong></p><p>Cloud Run servislerinize custom domainler tanımlayabildiğiniz gibi Cloud Run’da oluşturulan her bir servis için aşağıdaki gibi bir pattern’de özel olarak HTTPS URL’ler oluşturulur.</p><p><a href="https://servicename-unique_id-region_id.run.app/">https://SERVICENAME-UNIQUE_ID-REGION_ID.run.app</a></p><p><strong>Traffic splitting</strong></p><p>Cloud Run’da release ettiğiniz her bir değişiklik için bir revision oluşturulur ve gelen trafik %100&#39;ünü istediğiniz bir revision’a yönlendirebileceğiniz gibi trafik bu revisionlar arasında istediğiniz oranda paylaştırabilirsiniz.</p><p>Böylelikle örneğin yeni bir release yaptınız ve bu release’de bir bug olduğunu fark ettiniz. Hemen eski release’a trafik yönlendirip yeni release’i geri çekip düzeltme yapabilirsiniz.</p><p>Ya da yeni bir release yaptınız ve bu release’de bir performans iyileştirmesi yaptınız. Hemen yeni release’a %10 trafik yönlendirip performans iyileştirmesinin doğ</p><p>ru çalıştığından emin olduktan sonra %100&#39;e çıkarabilirsiniz.</p><p><strong>Revision URLs (Tagging)</strong></p><p>Cloud Run’da her bir release için bir revision oluşturulduğunu ve trafik bunlar arasında paylaştırabildiğimizi biliyoruz. Peki, her bir revisionları tag’leyebildiğimizi ve bunlara trafik yönlendirmemize gerek kalmadan direkt olarak o tag ile erişebildiğimizi söylesem? Muhteşem değil mi?</p><p>Kafanızda bir use-case canlanmamış olabilir ama bunu duyunca seveceğinizi düşünüyorum. Eski şirketimizde gönderilen her pull-request için CI/CD pipelanimiz çalışırdı ve bu pipeline sonucunda oluşan Docker imajını bir Docker registry’e push ederdik. Bu imajları da Cloud Run’da çalıştırırdık. Bu imajların tag’lerini ise pull-request numarası olarak belirlerdik. Böylelikle her bir pull-request için bir revision oluşturulur ve bu revision’a pull-request numarası ile erişebilirdik. Böylelikle pull-request’in sonucunu test etmek için herhangi bir deploy yapmamıza gerek kalmazdı.</p><p>Örnek olarak: <a href="https://xx-2125-add-foo-bar.run.app/">https://xx-2125-add-foo-bar.run.app</a></p><p><strong>HTTP/2, WebSockets, and gRPC</strong></p><p>Cloud Run’da HTTP/2, WebSockets ve gRPC desteği mevcuttur.</p><p><strong>Free tier</strong></p><p>Cloud Run’da her ay 180.000 saniye ücretsiz çalışma süresi bulunmaktadır. Bu süreyi 1 instance ile 180.000 saniye çalıştırabileceğiniz gibi 180.000 instance ile 1 saniyede çalıştırabilirsiniz. Bu ücretsiz süreyi kullanarak Cloud Run’u deneyebilirsiniz.</p><p><a href="https://cloud.google.com/run/pricing">https://cloud.google.com/run/pricing</a><br><a href="https://cloud.google.com/run">https://cloud.google.com/run</a></p><h4>3. GCP Cloud SQL</h4><p>GCP Cloud SQL, MySQL, PostgreSQL ve SQL Server veritabanlarını yönetmek için bir serverless hizmettir. Bu hizmeti kullanarak veritabanınızın yönetimini Google’a devredebilirsiniz.</p><p><strong>Compatibility (MySQL, PostgreSQL, Microsoft SQL Server)</strong></p><p>GCP Cloud SQL, MySQL, PostgreSQL ve SQL Server veritabanlarını desteklemektedir.</p><p><strong>Built-in high availability</strong></p><p>GCP Cloud SQL, veritabanınızın yüksek erişilebilir olmasını sağlamak için built-in high availability özelliğine sahiptir.</p><p><strong>Automatic storage increases</strong></p><p>GCP Cloud SQL, storage’ı otomatik olarak arttırabilir. Bu sayede veritabanınızın storage’ı dolmaya başladığında sizin hiçbir şey yapmanıza gerek kalmadan storage’ı otomatik olarak arttırabilir.</p><p><strong>Automatic backups</strong></p><p>GCP Cloud SQL, veritabanınızın otomatik olarak yedeğini alabilir. Bu sayede veritabanınızda bir problem olduğunda yedekten geri dönüş yapabilirsiniz. Ayrıca bu yedeklerin hangi zaman aralıklarıyla alınacağını siz belirleyebilirsiniz.</p><p><strong>Monitoring</strong></p><p>GCP Cloud SQL, veritabanınızın monitoringini yapabilir. Bu sayede veritabanınızda bir problem olduğunda bunu hemen fark edebilirsiniz.</p><p><a href="https://cloud.google.com/sql">https://cloud.google.com/sql</a></p><h4>4. GCP Cloud Memorystore</h4><p>GCP Cloud Memorystore, Redis ve Memcached veri depolama sistemlerini yönetmek için bir serverless hizmettir. Bu hizmeti kullanarak veri depolama sistemlerinizin yönetimini Google’a devredebilirsiniz.</p><p><strong>Compatibility (Redis, Memcached)</strong></p><p>GCP Cloud Memorystore, Redis ve Memcached veri depolama sistemlerini desteklemektedir.</p><p>GCP Cloud Memorystore’un biraz pahalı olduğunu söylemekte fayda var.</p><p><a href="https://cloud.google.com/memorystore">https://cloud.google.com/memorystore</a></p><h4>5. GCP Cloud Scheduler</h4><p>GCP Cloud Scheduler, aslında bir serverless cron job yöneticisidir. Bu hizmeti kullanarak cron job’larınızın yönetimini Google’a devredebilirsiniz.</p><p><strong>Support for Unix cron format</strong></p><p>GCP Cloud Scheduler, Unix cron formatını desteklemektedir.</p><p><strong>Configurable retry policy</strong></p><p>GCP Cloud Scheduler, cron job’larınızın tekrar deneme sayısını ve aralığını sizin belirleyebilmenizi sağlamaktadır. Örneğin, bir cron job hata aldığında sizin belirlediğiniz aralıkta tekrar denemesini sağlayabilirsiniz.</p><p><strong>Many supported targets</strong></p><p>GCP Cloud Scheduler, App Engine, Cloud Pub/Sub ve HTTP endpointlerini desteklemektedir. Böylelikle cron job’larınızın sonucunu App Engine, Cloud Pub/Sub ve HTTP endpointlerine gönderebilirsiniz.</p><p><a href="https://cloud.google.com/scheduler">https://cloud.google.com/scheduler</a></p><h4>6. GCP Cloud Tasks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bs3r-KCiXgNgNhrA05e49Q.png" /></figure><p>GCP Cloud Tasks, sıklıkla GCP Cloud Pub/Sub ile karşılaştırılmaktadır. GCP Cloud Pub/Sub ile GCP Cloud Tasks arasındaki farkları aşağıdaki şekilde özetleyebiliriz:</p><p><strong>İletişim Modeli:</strong> Cloud Tasks, doğrudan hedeflenen bir uygulamaya görevlerin iletilmesini sağlar. Bu görevler, hedef uygulamanın bir işlemi gerçekleştirmesi gereken iş birimlerini temsil eder. Cloud Pub/Sub ise olay tabanlı bir mesajlaşma sistemi olarak çalışır. Yayınlanan mesajlar, birden çok aboneye iletilir ve aboneler bu mesajları işler.</p><p><strong>Mesajlaşma Tipi: </strong>Cloud Tasks, işlemi tamamlanması gereken görevleri temsil eden tek bir mesajı yönetir. Görev, belirli bir iş birimini temsil eder ve hedeflenen uygulamaya iletilir. Cloud Pub/Sub ise birden çok aboneye iletilen olayları temsil eden yayınlanmış mesajlarla çalışır.</p><p><strong>Mesaj Saklama Süresi:</strong> Cloud Tasks, görevleri tutmak için kısa bir süre (varsayılan olarak 7 gün) saklar ve daha sonra siler. Cloud Pub/Sub ise mesajları bir süre (varsayılan olarak 7 gün) saklar ve abonelerin bu süre içinde mesajları işlemesine izin verir.</p><p><strong>Mesajların Yönetimi:</strong> Cloud Pub/Sub, yayınlanmış mesajları birden çok aboneye dağıtırken, Cloud Tasks belirli bir görevi doğrudan hedeflenen uygulamaya iletmek için kullanılır. Cloud Tasks, görevlerin oluşturulması, planlanması ve yönetimi için bir arayüz sağlar. Cloud Pub/Sub ise mesajlar üzerinde yayın/abonelik işlemlerini yönetmek için kullanılır.</p><p><strong>Senkron ve Asenkron İşlemler:</strong> Cloud Tasks, senkron veya asenkron işlemler için kullanılabilir. Görevler, hedeflenen uygulama tarafından senkron olarak işlenebilir veya hedeflenen uygulama, işi başlatır ve sonucu almak için daha sonra geri dönüş bekleyebilir. Cloud Pub/Sub ise genellikle asenkron mesajlaşma senaryolarında kullanılır, yani mesaj gönderen ve mesaj alan arasında doğrudan senkron bir etkileşim olmaz.</p><p>Bu farklar göz önüne alındığında, Cloud Tasks, belirli bir hedef uygulamaya görevlerin yönlendirilmesi ve işlenmesi için kullanılırken, Cloud Pub/Sub, olay tabanlı mesajlaşma ve abonelik işlemleri için kullanılır. İhtiyaçlarınıza ve kullanım senaryolarınıza bağlı olarak doğru hizmeti seçebilirsiniz.</p><p><strong>Rate and retry controls</strong></p><p>GCP Cloud Tasks, görevlerinizi belirli bir oranda çalışmasını ve belirli bir aralıkta</p><p>tekrar denemesini sağlayabilirsiniz.</p><p><strong>Guaranteed delivery</strong></p><p>GCP Cloud Tasks, görevlerinizi garanti eder. Örneğin, bir HTTP endpoint’e bir task gönderdiğinizde bu task’in HTTP endpoint’e ulaştığını garanti eder.</p><p><strong>Future scheduling</strong></p><p>GCP Cloud Tasks, task’lerinizi ileri bir tarihte çalışmasını sağlayabilirsiniz. Örneğin, bir task’ın 1 hafta sonra çalışmasını sağlayabilirsiniz.</p><p><strong>Task deduplication</strong></p><p>Task’lara vereceğiniz ID’ler sayesinde aynı ID’yi yanlışlıkla tekrar gönderdiğinizde GCP Cloud Tasks bu task’i duplicate olarak algılar ve duplicate task’i göndermez. Böylelikle duplicate task’lerinizi engellemiş olursunuz.</p><p>Task kuyruktan silindikten iki saat sonrasına kadar aynı ID’ye sahip task’i gönderemezsiniz.</p><p><a href="https://cloud.google.com/tasks">https://cloud.google.com/tasks</a></p><h4>7. GCP Cloud Load Balancer</h4><p>GCP Cloud Load Balancer, yük dengeleme işlemlerini gerçekleştirmenizi sağlar. Aşağıdaki özellikleri bulunur:</p><p><strong>HTTP(S) load balancing</strong></p><p>HTTP(S) load balancing ile HTTP ve HTTPS trafiği, farklı bölgelerde bulunan farklı servislere path, host ve URL parametrelerine göre yönlendirilebilir. Tek bir IP adresi ile farklı servisler arasında yük dengelemesi yapabilirsiniz.</p><p><strong>TCP/SSL load balancing</strong></p><p>TCP/SSL load balancing, trafiği Compute Engine havuzundaki sanal makinelerinize yönlendirmenizi sağlar.</p><p><strong>SSL offload</strong></p><p>SSL sertifikalarınızı merkezi olarak yönetebilir ve kaynak ile load balancer arasında veya kaynak ile hedef arasındaki iletişimi şifreleyebilirsiniz.</p><p><strong>High fidelity health checks</strong></p><p>Yük dağıttığınız servislerin sağlık durumunu kontrol edebilir, sağlık durumu bozulan servisleri yük dengeleyiciden çıkarabilirsiniz.</p><p><strong>Affinity</strong></p><p>Affinity ile gelen isteklerin aynı kaynağa yönlendirilmesini sağlayabilirsiniz.</p><p><strong>Cloud CDN integration</strong></p><p>Cloud CDN ile yük dengeleyicinizin önüne CDN ekleyerek, backend servislerinizin yanıtlarını önbelleğe alabilirsiniz. Bu şekilde backend servislerine yönlendirilen istek sayısını azaltabilirsiniz.</p><p><strong>Cloud Armor</strong></p><p>Cloud Armor ile load balancer’ınızın önüne ekleyeceğiniz WAF (Web Uygulama Güvenliği) ile gelen istekleri filtreleyebilirsiniz. (Bu özellik biraz maliyetlidir.)</p><p>GCP Cloud Load Balancer, yük dengeleme işlemlerini esnek ve güvenli bir şekilde gerçekleştirmenizi sağlar.</p><p><a href="https://cloud.google.com/load-balancing">https://cloud.google.com/load-balancing</a></p><h4>8. GCP Cloud Identity Platform</h4><p>Gelelim serimizin en son ve en sevdiğim kahramanı olan GCP Cloud Identity Platform’a. Sürekli login, register, forgot password, reset password, email verification, phone verification, social login, SSO, MFA, account protection gibi işlerle uğraşmak istemiyorsanız GCP Cloud Identity Platform tam size göre.</p><p><strong>Broad protocol support (SAML, OIDC, email/password, social, phone, and custom auth)</strong></p><p>GCP Cloud Identity Platform ile SAML, OIDC, email/password, social, phone ve custom auth gibi birçok protokolü destekleyen bir login sistemi oluşturabilirsiniz.</p><p><strong>Multi-tenancy</strong></p><p>Örneğin son kullanıcılarınızı ve admin kullanıcılarınızı ayrı ayrı veritabanlarında farklı şekillerde yönetmek istiyorsunuz. Bunun için GCP’de farklı projeler oluşturmanıza gerek kalmadan multi-tenancy özelliği ile bunu yapabilirsiniz.</p><p><strong>Bonus: </strong>GCP Cloud Identity Platform, GCP Cloud Identity-Aware Proxy ile entegre çalıştırarak tek tuş ile bazı servislerinizin önüne login ekleyebilirsiniz. Böylelikle login olmayan kullanıcıların servislerinize erişmesini engelleyebilirsiniz.</p><p><a href="https://cloud.google.com/iap">https://cloud.google.com/iap</a><br><a href="https://cloud.google.com/identity-platform">https://cloud.google.com/identity-platform</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9591afb5ec45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/teknasyon-engineering/accelerate-your-time-to-market-with-serverless-9591afb5ec45">Accelerate your “Time to Market” with Serverless</a> was originally published in <a href="https://medium.com/teknasyon-engineering">Teknasyon Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to write unit tests for http clients in Go]]></title>
            <link>https://medium.com/teknasyon-engineering/how-to-write-unit-tests-for-http-clients-in-go-5de79aa4f92?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/5de79aa4f92</guid>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Tue, 02 Aug 2022 10:22:26 GMT</pubDate>
            <atom:updated>2024-09-17T07:20:51.067Z</atom:updated>
            <content:encoded><![CDATA[<p>Most of the applications have to communicate with external services. Sometimes the external services might don’t have a client library for Go. So, you have to write your own http client to communicate with them.</p><p>Unit tests are a good way to test the behavior of your software. In this article, I will try to show how to write testable http client in Go.</p><p>In this example I will write a simple http client for the Rick and Morty API and I will test it.</p><p>You can find the Rick and Morty API <a href="https://rickandmortyapi.com/documentation/#rest">here</a></p><p>This is our API Client</p><pre>// client.go<br>package rickandmorty<br><br>import (<br> &quot;encoding/json&quot;<br> &quot;fmt&quot;<br> &quot;io/ioutil&quot;<br> &quot;net/http&quot;<br>)<br><br>// APIError represents an 4xx error from the API.<br>type APIError struct {<br> Err string `json:&quot;error&quot;`<br>}<br><br>func (e *APIError) Error() string {<br> return e.Err<br>}<br><br>func NewClient(baseURL string) *Client {<br> return &amp;Client{<br>  client:  &amp;http.Client{},<br>  baseURL: baseURL,<br> }<br>}<br><br>type Client struct {<br> client  *http.Client<br> baseURL string<br>}<br><br>type Character struct {<br> ID      int    `json:&quot;id&quot;`<br> Name    string `json:&quot;name&quot;`<br> Status  string `json:&quot;status&quot;`<br> Species string `json:&quot;species&quot;`<br> Type    string `json:&quot;type&quot;`<br> Gender  string `json:&quot;gender&quot;`<br> Image   string `json:&quot;image&quot;`<br> URL     string `json:&quot;url&quot;`<br> Created string `json:&quot;created&quot;`<br>}<br><br>// GetCharacter returns a character by ID.<br>func (c *Client) GetCharacter(id int) (*Character, error) {<br> req, err := http.NewRequest(http.MethodGet, fmt.Sprintf(&quot;%s/character/%d&quot;, c.baseURL, id), nil)<br> if err != nil {<br>  return nil, fmt.Errorf(&quot;error creating request: %w&quot;, err)<br> }<br> req.Header.Set(&quot;Accept&quot;, &quot;application/json&quot;)<br> req.Header.Set(&quot;Content-Type&quot;, &quot;application/json&quot;)<br><br> var character Character<br> if err := c.makeRequest(req, &amp;character); err != nil {<br>  return nil, err<br> }<br><br> return &amp;character, nil<br>}<br><br>// makeRequest makes a request to the API and unmarshals the response into the given interface.<br>func (c *Client) makeRequest(r *http.Request, v interface{}) error {<br> resp, err := c.client.Do(r)<br> if err != nil {<br>  return err<br> }<br> defer resp.Body.Close()<br><br> data, err := ioutil.ReadAll(resp.Body)<br> if err != nil {<br>  return fmt.Errorf(&quot;error reading response body: %w&quot;, err)<br> }<br><br> switch status := resp.StatusCode; {<br> case status &gt;= 200 &amp;&amp; status &lt; 300: // 2xx<br>  if err := json.Unmarshal(data, v); err != nil {<br>   return fmt.Errorf(&quot;error unmarshalling response: %w&quot;, err)<br>  }<br>  return nil<br> case status &gt;= 400 &amp;&amp; status &lt; 500: // 4xx<br>  var apiError APIError<br>  if err := json.Unmarshal(data, &amp;apiError); err != nil {<br>   return fmt.Errorf(&quot;error unmarshalling response: %w&quot;, err)<br>  }<br>  return &amp;apiError<br> default: // 5xx<br>  return fmt.Errorf(&quot;error response: %s&quot;, string(data))<br> }<br>}</pre><p>There are several ways to test the http client like httptest.Server, But in this case I will use the http.Transport.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJnUyLtayWv_N8Ngj1osIQ.png" /><figcaption>net/http.Client.go</figcaption></figure><p>Instead of to use default http.Transport we will replace it with a custom transport that will return a specific response for each request.</p><p>To implement a transport we will use the http.RoundTripper interface. The RoundTripper interface is implemented by the http.Transport struct.</p><p>This interface has just one method RoundTrip(*Request) (*Response, error) that is used to make a request and return the response.</p><p>From the Go documentation: <a href="https://golang.org/pkg/net/http/#RoundTripper">https://golang.org/pkg/net/http/#RoundTripper</a></p><p>Go standard library already has everything we need to write tests.</p><p>So let’s write a test for our client and cover the following cases:</p><ul><li>GetCharacter returns a character by ID.</li><li>GetCharacter returns an error if the character doesn’t exist.</li><li>GetCharacter returns an error if the API returns an error.</li></ul><pre>// client_test.go<br>package rickandmorty<br><br>import (<br> &quot;io/ioutil&quot;<br> &quot;net/http&quot;<br> &quot;strings&quot;<br> &quot;testing&quot;<br>)<br><br>type RoundTripFunc func(req *http.Request) *http.Response<br><br>func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {<br> return f(req), nil<br>}<br><br>// Test4xxError tests that a 4xx error is returned as an APIError.<br>func Test4xxError(t *testing.T) {<br> hclient := &amp;http.Client{Transport: RoundTripFunc(func(req *http.Request) *http.Response {<br>  return &amp;http.Response{<br>   StatusCode: http.StatusBadRequest,<br>   Body:       ioutil.NopCloser(strings.NewReader(`{&quot;error&quot;:&quot;Character not found&quot;}`)),<br>  }<br> })}<br><br> client := Client{client: hclient, baseURL: &quot;https://rickandmortyapi.com/api&quot;}<br><br> _, err := client.GetCharacter(-1) // -1 is not a valid character ID so this should return an error<br> if err == nil {<br>  t.Error(&quot;expected error, got nil&quot;)<br> }<br><br> apiError, ok := err.(*APIError)<br> if !ok {<br>  t.Error(&quot;expected error to be of type APIError&quot;)<br> }<br> if apiError.Err != &quot;Character not found&quot; {<br>  t.Errorf(&quot;expected error message to be Character not found, got %s&quot;, apiError.Err)<br> }<br>}<br><br>// Test5xxError tests that a 5xx error is returned as an APIError.<br>func Test5xxError(t *testing.T) {<br> hclient := &amp;http.Client{Transport: RoundTripFunc(func(req *http.Request) *http.Response {<br>  return &amp;http.Response{<br>   StatusCode: http.StatusInternalServerError,<br>   Body:       ioutil.NopCloser(strings.NewReader(`Internal server error`)),<br>  }<br> })}<br><br> client := Client{client: hclient, baseURL: &quot;https://rickandmortyapi.com/api&quot;}<br><br> _, err := client.GetCharacter(1)<br> if err == nil {<br>  t.Error(&quot;expected error, got nil&quot;)<br> }<br><br> if _, ok := err.(*APIError); ok {<br>  t.Error(&quot;expected error to not be of type APIError&quot;)<br> }<br>}<br><br>func TestGetCharacterByID(t *testing.T) {<br> characterJSON := `{&quot;id&quot;:2,&quot;name&quot;:&quot;Morty Smith&quot;,&quot;status&quot;:&quot;Alive&quot;,&quot;species&quot;:&quot;Human&quot;,&quot;type&quot;:&quot;&quot;,&quot;gender&quot;:&quot;Male&quot;,&quot;image&quot;:&quot;https://rickandmortyapi.com/api/character/avatar/2.jpeg&quot;,&quot;url&quot;:&quot;https://rickandmortyapi.com/api/character/2&quot;,&quot;created&quot;:&quot;2017-11-04T18:50:21.651Z&quot;}`<br><br> hclient := &amp;http.Client{Transport: RoundTripFunc(func(req *http.Request) *http.Response {<br>  if req.URL.String() != &quot;https://rickandmortyapi.com/api/character/2&quot; {<br>   t.Error(&quot;expected request to https://rickandmortyapi.com/api/character/2, got&quot;, req.URL.String())<br>  }<br>  if req.Method != &quot;GET&quot; {<br>   t.Error(&quot;expected request method to be GET, got&quot;, req.Method)<br>  }<br>  if req.Header.Get(&quot;Accept&quot;) != &quot;application/json&quot; {<br>   t.Error(&quot;expected request Accept header to be application/json, got&quot;, req.Header.Get(&quot;Accept&quot;))<br>  }<br>  if req.Header.Get(&quot;Content-Type&quot;) != &quot;application/json&quot; {<br>   t.Error(&quot;expected request Content-Type header to be application/json, got&quot;, req.Header.Get(&quot;Content-Type&quot;))<br>  }<br><br>  return &amp;http.Response{<br>   StatusCode: http.StatusOK,<br>   Body:       ioutil.NopCloser(strings.NewReader(characterJSON)),<br>  }<br> })}<br><br> client := Client{client: hclient, baseURL: &quot;https://rickandmortyapi.com/api&quot;}<br><br> character, err := client.GetCharacter(2)<br> if err != nil {<br>  t.Errorf(&quot;unexpected error: %v&quot;, err)<br> }<br><br> if character.ID != 2 {<br>  t.Errorf(&quot;expected character ID to be 2, got %d&quot;, character.ID)<br> }<br> if character.Name != &quot;Morty Smith&quot; {<br>  t.Errorf(&quot;expected character name to be Morty Smith, got %s&quot;, character.Name)<br> }<br>}</pre><p>Then run the tests:</p><pre>$ go test -v ./...</pre><pre>=== RUN   Test4xxError</pre><pre>--- PASS: Test4xxError (0.00s)</pre><pre>=== RUN   Test5xxError</pre><pre>--- PASS: Test5xxError (0.00s)</pre><pre>=== RUN   TestGetCharacterByID</pre><pre>--- PASS: TestGetCharacterByID</pre><p>All tests passed :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5de79aa4f92" width="1" height="1" alt=""><hr><p><a href="https://medium.com/teknasyon-engineering/how-to-write-unit-tests-for-http-clients-in-go-5de79aa4f92">How to write unit tests for http clients in Go</a> was originally published in <a href="https://medium.com/teknasyon-engineering">Teknasyon Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nedir bu server-side-rendering(ssr) ve client-site-rendering(csr)]]></title>
            <link>https://alioygur.medium.com/nedir-bu-server-side-rendering-ssr-ve-client-site-rendering-csr-bcf4a80e1b50?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf4a80e1b50</guid>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nuxtjs]]></category>
            <category><![CDATA[client-side-rendering]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Fri, 08 Jan 2021 15:54:08 GMT</pubDate>
            <atom:updated>2021-01-08T15:54:08.168Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yk0pUiCL1CZP9j194O9t5Q.jpeg" /></figure><p>React, VueJS ve Angular gibi javascript frameworkler populer olduktan sonra client-side-rendering, server-side-rendering, prerender gibi kavramlarla sikca karsilasmaya basladik ve bazilarimizin kafasi iyice karisti.</p><p>Yazi yerine mumkun oldugunca diagram kullanarak konuyu anlatmaya calisacagim.</p><p>Aslinda konuyu iki baslik altinda ozetleyebiliriz, client-side-rendering ve server-side-rendering</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRftPL0mxSxiVSg-E0P7IA.png" /><figcaption>Client Side Rendering</figcaption></figure><p>Browser sunucuya bir istek yapar, sunucu yanit olarak basit bir HTML dosyasi icerisine gomulu bir .js dosyasi dondurur, tarayici da bu .js dosyasini yorumlayarak HTML+CSS’e donusturur ve sayfa hazirdir.</p><p>Reac, VueJS ve Angular gibi js frameworkleri bu sekilde calisir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DqeuoMmpvUjR_0DIylDYZA.png" /><figcaption>Server Side Rendering</figcaption></figure><p>Browser sunucuya istek yapar, sunucu da ilgili sayfanin ham .js dosyasini direkt donmek yerine render eder ve HTML+CSS ciktisini browser’a gonderir.</p><p><a href="https://nextjs.org/">NextJS</a> (React icin SSR) ve <a href="https://nuxtjs.org/">NuxtJS</a> (Vue icin SSR)</p><p>SEO kayginiz yoksa SSR kullanmaniza gerek olmayabilir, SSR’in ortaya cikisindaki en buyuk itme motivasyonu SEO’dur.</p><p>SSR konusunu uc baslik altinda inceleyebiliriz;</p><h4><strong>1. Dynamic SSR</strong></h4><p>Varsayilan SSR diyebiliriz buna, yukaridaki SSR diagraminda da gosterdigimiz gibi sunucuya istek yapildiginda ilgili sayfa render edilir ve client’a iletilir. “on-demand”</p><p><strong>Ne zaman kullanilir:</strong> cok buyuk ve surekli degisen sayfalariniz varsa bu yontemi kullanabilirsiniz. NextJS ve NuxtJS varsayilan olarak bu sekilde calismaktadir.</p><blockquote>Yogun trafik alan sitelerde ciddi sunucu maliyeti yaratabilir.!</blockquote><h4>2. Static SSR</h4><p>Build edilirken butun sayfalar static olarak olusturulur ve sunucuya yuklenir, sunucuya istek yapildiginda onceden olusturulmus static HTML dosyasi yanit olarak doner.</p><p>Sunucu tarafinda bir rendering(computing) yapilmadigindan Dynamic SSR’a gore cok daha hizlidir, hatta bu sekilde olusturulmus bir websitesi GCP Cloud Storage ya da AWS S3&#39;e direkt olarak yuklenebilir.</p><p><strong>Ne zaman kullanilir: </strong>sayfa sayisi fazla olmayan, statik yani degismeyen sitelerde kullanilabilir.</p><p><a href="https://nuxtjs.org/docs/2.x/concepts/static-site-generation">Static Site Generation</a></p><p><a href="https://nextjs.org/docs/advanced-features/static-html-export">https://nextjs.org/docs/advanced-features/static-html-export</a></p><h4>3. Hybrid SSR</h4><p>Adindan da anlasilacagi uzere dynamic ve static ssr’i ayni anda kullanabilirsiniz.</p><p><a href="https://tools.ietf.org/html/rfc5861">stale-while-revalidate</a> prensibinden esinlenerek yapilmistir. Ozetle her sayfa icin bir sure belirtiyorsunuz, o sure doldugunda ilgili sayfa tekrar olusturuluyor ve yeniden olusturulana kadar mevcut kopyadan sunuluyor.</p><blockquote>Surekli bir rendering ihtiyaci olacagi icin server’a ihtiyac duyar.</blockquote><p>NextJS bu konuda acik ara NuxtJS’den ondedir.</p><p><a href="https://nextjs.org/docs/basic-features/data-fetching">Basic Features: Data Fetching | Next.js</a></p><p><strong>Bonus:</strong> Son zamanlarda adi sikca duyulan <a href="https://jamstack.org/">jamstack</a> kavrami da yukarida aciklamaya calistigim yontemlerden fazlasi degildir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf4a80e1b50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Run’da Environment degiskenlerini guvenli bir sekilde saklamak]]></title>
            <link>https://alioygur.medium.com/cloud-runda-environment-degiskenlerini-guvenli-bir-sekilde-saklamak-adcf6efed6d0?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/adcf6efed6d0</guid>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Sun, 06 Dec 2020 19:59:01 GMT</pubDate>
            <atom:updated>2020-12-06T20:11:05.714Z</atom:updated>
            <content:encoded><![CDATA[<p>Docker ile birlikte ortam degiskenlerini dogru bir sekilde kullanmak cok daha onemli bir hale geldi.</p><p>Eger “Dockerize” ettiginiz bir proje icin prod, stage ve test gibi ortamlar icin ayri ayri build ediyorsaniz cok buyuk bir hata yapiyorsunuz.</p><blockquote>Build once run everywhere.</blockquote><p>Bir uygulamanin prod, stage ve test gibi ortamlarda farkli davranmasini istiyorsaniz bunu kesinlikle codebase’de bir degisiklik yapmaniza gerek kalmadan yapmalisiniz.</p><p>The Twelve Factor App’i okumadiysaniz kesinlikle okumanizi oneririm, zira 3. konusu Config’dir.</p><p><a href="https://12factor.net/config">The Twelve-Factor App</a></p><p>Environment’larin kendisi bu yazinin konusu olmadigi icin uzerinde cok durmadan bu yazinin asil konusu olan Cloud Run’da ortam degiskenlerini nasil kullaniriz ve guvenligini nasil saglariz konusunu konusalim.</p><p>Cloud Run’da bir versiyon cikarken o versiyona ozel ortam degiskenlerini girebiliyorsunuz; ancak bunlar “plain text” saklanir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gb8RS2iCW7YmwDl9p2SGvw.png" /></figure><p>Cok kucuk ekipler icin bu problem olmayabilir ancak birden fazla kisinin bulundugu ekiplerde bu problem olabilir. Bir GCP Projesinde “viewer” rolundeki kisi bile sizin production database’inizin bilgilerini ogrenebilir.</p><p>Yazilimcilari GCP’ye almayalim da diyebilirsiniz ancak devops kulturune aykiridir. Yazilimci, yazdigi kodu nerede nasil calistigini bilmeli, mumkun oldugunca bu sureclere dahil edilmelidir.</p><p>Cloud Run, hassas ortam degiskenlerinin <a href="https://cloud.google.com/secret-manager">secret manager</a>’da saklanmasini oneriyor.</p><p>Secret manager cok guzel bir tool ancak eksik bir parca var, bu verilere uygulama icerisinde erismek icin ekstra kod yazmaniz gerekiyor ancak bazi problemler var;</p><ul><li>Local development esnasinda codebase’e ekstra bir if yazmak gerekiyor. env == local {ortam degiskenlerini kullan} else {gcp secret kullan}</li><li>Uygulamamizi platform bagimli bir hale getiriyor, GCP’den baska bir platform’a goc ettigimizde codebase’de degisiklik yapmak zorunda kalacagiz.</li></ul><p>Bir arkadas bu eksik parcayi muhtesem bir sekilde tamamlamis ve kucuk ve etkili bir arac gelistirmis.</p><p><a href="https://github.com/binxio/gcp-get-secret">binxio/gcp-get-secret</a></p><p>Bu arkadasin yaptigi sey su;</p><ul><li>Dockerfile’iniza bu script’i entrypoint olarak giriyorsunuz;</li><li>Uygulamanizda Environment degiskeninin degerine de GCP secret manager’daki secret’in adini yaziyorsunuz. ornegin MYSQL_PASSWORD=gcp:///mysql_password</li><li>Ilgili script run time’da MYSQL_PASSWORD=gcp:///mysql_password ‘un gcp secret oldugunu anliyor ve bunun degerini cekip ilgili environment degerini guncelliyor, yani MYSQL_PASSWORD=123456 seklinde app’e geciyor.</li></ul><p>Sizinle tatil.com’da bulunan bir servisin dockerfile’ini oldugu gibi paylasiyorum, ilgili satirlari bold yaptim.</p><pre>FROM golang:1.15</pre><pre>WORKDIR /app</pre><pre>COPY go.mod go.sum ./</pre><pre>RUN go mod download</pre><pre>COPY . ./</pre><pre>RUN CGO_ENABLED=0 GOOS=linux go build -v -o server</pre><pre><strong>FROM binxio/gcp-get-secret</strong></pre><pre>FROM alpine:3</pre><pre>RUN apk add — no-cache ca-certificates tzdata</pre><pre>ENV TZ Europe/Istanbul</pre><pre>COPY — from=0 /app/server /usr/local/bin/</pre><pre><strong>COPY — from=1 /gcp-get-secret /usr/local/bin/</strong></pre><pre><strong>ENTRYPOINT [ “gcp-get-secret”]</strong></pre><pre>CMD [“server”]</pre><p><em>Bu arada Docker multi stage build ile bu islerin ne kadar zarif olduguna bakar misiniz… sonsuz tesekkurler.</em></p><p>Ayni servisin GCP Cloud Run ekran goruntusu;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKcYu5yNrlDrUdh2lBRhVQ.png" /></figure><h3>Sonuc</h3><p>Veritabani sifreleri gibi hassas verilerimizi GCP Secret Manager’da guvenli bir sekilde sakladik ve uygulamamizin codebase’inde bir satir degisiklik yapmadan bu verileri standart bir ortam degiskeni gibi kullandik.</p><p>Tesekkurler.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adcf6efed6d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Derinlemesine CORS]]></title>
            <link>https://alioygur.medium.com/derinlemesine-cors-88ed0c80123c?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/88ed0c80123c</guid>
            <category><![CDATA[cors]]></category>
            <category><![CDATA[ajax]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Mon, 25 Sep 2017 22:28:27 GMT</pubDate>
            <atom:updated>2017-09-27T09:09:52.362Z</atom:updated>
            <content:encoded><![CDATA[<p>Her genc developer buna benzer bir hata ile karsilasmistir.</p><blockquote>No ‘Access-Control-Allow-Origin’ header is present on the requested resource.</blockquote><p>Kimimiz bu problem ile yuzlestiginde hemen bir google’layip karsisina cikan kodlari copy-paste edip cozmustur problemi, kimimiz de derinlemesine ogrenmek icin arastirmalar yapmistir. Bu makalede derinlemesine incelemeye calisacagiz bu CORS olayini.</p><p>Acilimi, <strong>C</strong>ross-<strong>O</strong>rigin <strong>R</strong>esource <strong>S</strong>haring’dir</p><p>Browserlar ontanimli olarak, eger x.com’dan, x.com olmayan farkli bir alan adina request yapildiginda, bu bir ajax request’i olabilir, request’i gerceklestirmeden once hedef alan adina sahte(preflight) bir request gerceklestirerek hedef alan adinin kaynak alan adina izin verip vermedigini sorar, izin varsa gercek istegi gerceklestirir, yoksa browser’in consol’una “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” gibi bir hata basar.</p><p><strong>Bu guvenlik onleminin en buyuk amaci CSRF ataklarini engellemektir.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*hRl9D4aVvmRhIGTewUPBPg.png" /></figure><p>Preflight request ozetle der ki, hey hedef domain, x.com sana METHOD’u su, HEADER’lari sunlar olan bir request yapmak istiyor, sen bunu kabul ediyor musun?, hedef domain’in de dondugu HEADER’lardan bu istegi kabul edip etmedigine karar verdikten sonra asil istegi yapar veya iptal eder.</p><h3>Preflight request’i yapilirken su header’lar gonderilir</h3><h4>Origin: x.com</h4><p>Request bu domain’den yapilacak.</p><h4>Access-Control-Request-Method: PUT</h4><p>Request’in METHOD’u PUT olacak</p><h4>Access-Control-Request-Headers: X-Custom-Header</h4><p>Request’in HEADER’lari sunlar olacak</p><h3>Response Headers</h3><h4>Access-Control-Allow-Origin: x.com</h4><p>ben sadece bu domain’lere izin veriyorum</p><h4>Access-Control-Allow-Methods: PUT</h4><p>Ben sadece bu method’lara izin veriyorum</p><h4><strong>Access-Control-Allow-Headers: X-Custom-Header</strong></h4><p>Ben sadece bu header’lara izin veriyorum</p><p>Preflight request’i yapildiktan sonra, gelen response header’lara gore hedef adresin bu request’e izin verip vermedigine karar verilir ve asil request gerceklesir veya iptal edilir.</p><h3>Notlar</h3><ul><li>Kaynak ve hedef alan adlari ayni ise bu sartlar aranmaz, request direkt gerceklesir.</li><li>Bu kisitlama sadece browser’lar uzerinden yapilan request’ler icin gecerlidir, siz CURL veya POSTMAN gibi araclardan direkt request yapabilirsiniz, oralarda kimse CORS’u takmaz. :)</li><li>Response header’larda * herhangi anlamina gelir, yani asagidaki response, ben butun metod’lari kabul ediyorum anlamina gelir.<br>Access-Control-Allow-Methods: *</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88ed0c80123c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turkcell dolanırıcılarla iş birliği mi yapıyor?]]></title>
            <link>https://alioygur.medium.com/turkcell-dolan%C4%B1r%C4%B1c%C4%B1larla-i%C5%9F-birli%C4%9Fi-mi-yap%C4%B1yor-706d2110f91?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/706d2110f91</guid>
            <category><![CDATA[turkcell]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Tue, 24 Jan 2017 17:45:15 GMT</pubDate>
            <atom:updated>2017-01-24T17:45:15.631Z</atom:updated>
            <content:encoded><![CDATA[<p>Telefonuma sürekli “hergunhava” ve “iddaatahmin” tarafından gönderilen mesajları engelemmek için sms engelleme programı indirdim ve bunları engelledim.</p><p>Daha sonra ayda 49 tl gelmesi gereken turkcell faturamın 94 tl oldugunu görünce aşağıdaki panda gibi oldum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*FhFqyAOLrWJ83dWoij0mQw.gif" /></figure><p>Neyse direk müşteri hizmetlerini meşgul etmek yerine, telefonumdaki turkcell hesabım uygulamasından fatura detayıma bakim dedim neyin nesiymis. Asıl şoku o anda yaşadım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*8Y-iUiMzkCLFCvIud0HhiA.jpeg" /></figure><p>Ya bu uğruna sms engelleme uygulamaları indirdiğim iddaa ve hava durmu mesajlarının ücreti mi? ta kendisiymiş….</p><p>Ya ben rahatsız olduğum bu mesajları almak için üstüne para ödüyormuşum :)</p><p>Neyse işin peşini hemen bırakacak değiliz, müşteri hizmetlerini aradım. Dedim ki, böyle böyle bir durum var, ben bu servislere üye falan olmadım zaten hava durumuna bakmak istersem, ekranı sola kaydırıyorum Google bana ücretsiz bir şekilde 5 günlük hava durumunu gösteriyor. iddaa da hiç oynamadım ama, alakam olsa bile internetten ücretsiz bir şekilde tahminlere ulaşabilirim.</p><p>Dediler ki, Siz bu servislere şu şu tarihlerde üye olmuşsunuz. <br>Peki dedim nasıl olmuşum? Telefonunuza gelen mesajı onaylamışsınız.</p><p>Neyse mevcut üyeliğimi iptal ettirdim. ancak o an’a kadar olan ücreti ödemek zorunda kaldım.</p><p><strong>Peki bu servislere nasıl üye olmuşum biliyor musunuz?</strong></p><p>Bir telefon gürüşmesi yaptıktan sonra, telefonunuza “turkcell menu” başlıklı bir “popup” çıkıyor. Siz bunu masum bir bilgilendirme mesajı zannedip veya dalgınlığınıza gelip “ok”a bastığınız anda, şak diye sizi servise abone ediyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*2gjjjZh0Go4lgQxTk6n-RA.jpeg" /></figure><p>Dediğim gibi mesleğim itibari ile az çok bu işlerin olması gereken adil ve güvenli yolunun aşağıdaki gibi olması gerektiğini biliyorum.</p><p><strong>Müşterinin telefonuna bildirim düşer, müşteri tamam’a tıklar ise müşteriye bir onay sms’i gönderilir ve onaylaması için mesaj’a cevap olarak evet yazması gerekir.</strong></p><p>Ilgili sistemi yazanlar bu kadar akıllı değil mi diyeceksiniz tabii ki akıllılar ancak burada çok büyük bir art niyet var, burada müşteri memnuniyetini 2. plana atmış gözünü para bürümüş bir şirket var.</p><p>Turkcell burada binlerce insanın bunu masum bir bilginedirme mesajı zannedip tamam’a basarak madur olduğunu, yüzlerce şikayetin gelmesine rağmen sırf, <strong>haksız bir şekilde de olsa</strong>,<strong> aldatmaca ile bile olsa </strong>para kazanmak için yapmaktadır.</p><p>Son olarak dün “iziniptal” yazıp “2780”e göndermeme rağmen bügün telefonuma yine benzer bir bildirim düştü. Bildirimin ekran görüntüsünü aldım (ekran görüntüsünün alınma tarihini ıspat edebilmek için bügün tarihli bir haber içeriğinin içerisindeyken aldım)</p><p>Hiç abartmıyorum arkadaşlar müşteri hizmetleri bana özetle şunu dedi, bunlar özel servis ücretli olduğu için, siz izini iptal de etseniz, bazen engellenemiyor. :)</p><p>Burada tüm yazdıklarımın ilgili delilleri elimde mevcuttur. Önceleri şikayet edecektim ancak daha sonradan topluluğun gücünün, sosyal medya’nın gücünün hepsinden büyük olduğunu düşündüğüm için, bu şekilde bir hikaye oluşturmak istedim. Sizlerden ricam bunu paylaşarak kimsenin keriz olmadığını o büyük şirketlere hatırlatmanızdır.</p><blockquote>Dipnot: 3 yıl önce kaybolan kimliğimi biri bulup üzerine kendi resmini yapıştırıp turkcell’den kendisine, iphone 5 almıştı :) Yani o kullanacak ben ödeyecektim. Neyse ki onu uzun uğraşlar sonucu iptal ettiler.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=706d2110f91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[http.HandleFunc, http.HandlerFunc, http.Handle ve http.Handler nedir arasındaki farklar]]></title>
            <link>https://alioygur.medium.com/http-handlefunc-http-handlerfunc-http-handle-ve-http-handler-nedir-aras%C4%B1ndaki-farklar-59d06e4e9e94?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/59d06e4e9e94</guid>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Wed, 08 Jul 2015 00:00:00 GMT</pubDate>
            <atom:updated>2017-09-26T08:22:39.119Z</atom:updated>
            <content:encoded><![CDATA[<p>http.HandleFunc ve http.Handle function olarak kendi arasında, http.HandlerFunc’ı bir tip http.Handler’ı ise bir interface olarak kendi arasında iki guruba ayırabiliriz.</p><p>yukarıdaki ifadeleri guruplamamdaki amaç, aslında bir gurubun olmazsa olmaz diğer gurubun ise geliştiricilere kolaylık sağlamak amacı ile oluşturulduğunu göstermekdir.</p><p>net/http paketinin kullanımı hakkında örneklere baktığımızda üç farklı şekilde rota tanımlandığını görebiliyoruz.</p><p><strong>1. Yöntem</strong> (Zor olan)</p><pre>type IndexHandler struct{}<br><br>func (this IndexHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {<br>    rw.Write([]byte(&quot;Hellow World!&quot;))<br>}<br><br>func main() {<br>    http.Handle(&quot;/&quot;, IndexHandler{})<br><br>    http.ListenAndServe(&quot;:8000&quot;, nil)<br>}</pre><p><strong>2. Yöntem</strong> (Eh işte orta)</p><pre>func indexHandler(rw http.ResponseWriter, req *http.Request) {<br>    rw.Write([]byte(&quot;Hellow World!&quot;))<br>}<br><br>func main() {<br>    http.Handle(&quot;/&quot;, http.HandlerFunc(indexHandler))<br><br>    http.ListenAndServe(&quot;:8000&quot;, nil)<br>}</pre><p><strong>3. Yöntem</strong> (Kolay olan)</p><pre>func indexHandler(rw http.ResponseWriter, req *http.Request) {<br>    rw.Write([]byte(&quot;Hellow World!&quot;))<br>}</pre><pre>func main() {<br>    http.HandleFunc(&quot;/&quot;, indexHandler)</pre><pre>    http.ListenAndServe(&quot;:8000&quot;, nil)<br>}</pre><p>Nasıl ? sizce üçüncü yöntem çok daha kolay değil mi ? birinci yöntem’de bir struct oluşturacaksın daha sonra ona bir metod ekleyeceksin falan filan… ama üçüncü yöntemde tek bir fonksiyon ile hallediyoruz.</p><p>aslında arka plan’da tüm yöntemler 1. yönteme dönüşür!</p><p><strong>http.HandleFunc</strong></p><p>HandleFunc iki değer alan bir fonksiyondur, ilk değer path ikinci değer de bir fonksiyon’dur (http.HandlerFunc tipinde)</p><pre>func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {<br>    DefaultServeMux.HandleFunc(pattern, handler)<br>}</pre><p><strong>http.Handle</strong></p><p>handle iki değer alan bir fonksiyondur, ilk değer path ikinci değer de bir http.Handler interface’ine uygun ifadedir.</p><pre>func Handle(pattern string, handler Handler) {<br>        DefaultServeMux.Handle(pattern, handler) <br>}</pre><p><strong>http.HandlerFunc</strong></p><p>HandlerFunc, ServeHTTP adında bir metodu bulunan bir tiptir. bunun var oluş amacı kolay bir şekilde http.Handler interface’ine uygun struct’lar oluşturmakdır.</p><pre>type HandlerFunc func(ResponseWriter, *Request)<br><br>func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {<br>    f(w, r)<br>}</pre><p>ikinci yönteme dikkat ederseniz http.Handle() ile rota tanımlamamıza rağmen herhangi bir struct falan oluşturmadık. http.HandlerFunc bizim yerimize oluşturdu çünkü. bunu bir wrapper olarak düşünebilirsiniz. geriye http.Handler interface’ine uygun bir ifade döndürür.</p><p><strong>http.Handler</strong></p><p>http.Handler bir inerface’dir.</p><pre>type Handler interface {<br>    ServeHTTP(ResponseWriter, *Request)<br>}</pre><p><em>Originally published at </em><a href="http://alioygur.github.io/go/2015/07/08/httphandlefunc-httphandlerfunc-httphandle-ve-httphandler-nedir-arasndaki-farklar/"><em>alioygur.github.io</em></a><em> on July 8, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59d06e4e9e94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ab test aracı kullanımı]]></title>
            <link>https://alioygur.medium.com/ab-test-arac%C4%B1-kullan%C4%B1m%C4%B1-816479aaeefa?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/816479aaeefa</guid>
            <category><![CDATA[ab-testing]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Tue, 28 Apr 2015 00:00:00 GMT</pubDate>
            <atom:updated>2016-11-23T10:52:21.576Z</atom:updated>
            <content:encoded><![CDATA[<p>ab test aracı kullanımı</p><p>İsminden de anlaşılacağı üzere, araç Apache firmasınındır.</p><p>bu araç, bir web uygulamamısının performansını ölçmek için dizayn edilmiştir.</p><h3>Kullanım</h3><pre>ab -n “toplam istek sayısı” -c “eşzamnlı olarak kaç istek yapılacak” URL</pre><h3>Gerçek hayattan örnek,</h3><p>example.org adresine aynı anda 10 olmak üzere toplamda 100 http isteği gönderelim ve aracın çıktısını inceleyelim.</p><pre>ab -n 100 -c 10 example.org/</pre><p>yukarıdaki komutu çalıştırıp kısa bir süre bekledikten sonra aşağıdaki çıktı gibi bir çıktı alacağız.</p><pre>This is ApacheBench, Version 2.3 &lt;$Revision: 1528965 $&gt;<br>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>Licensed to The Apache Software Foundation, http://www.apache.org/<br><br>Benchmarking example.org (be patient).....done<br><br><br>Server Software:        ECS<br>Server Hostname:        example.org<br>Server Port:            80<br><br>Document Path:          /<br>Document Length:        1270 bytes<br><br>Concurrency Level:      10<br>Time taken for tests:   2.593 seconds<br>Failed requests:        0<br>Total transferred:      161000 bytes<br>HTML transferred:       127000 bytes<br>Requests per second:    38.56 [#/sec] (mean)<br>Time per request:       259.350 [ms] (mean)<br>Time per request:       25.935 [ms] (mean, across all concurrent requests)<br>Transfer rate:          60.62 [Kbytes/sec] received<br><br>Connection Times (ms)<br>              min  mean[+/-sd] median   max<br>Connect:      123  127   2.5    126     134<br>Processing:   126  129   2.4    128     135<br>Waiting:      125  129   2.4    128     134<br>Total:        249  256   4.9    254     269<br><br>Percentage of the requests served within a certain time (ms)<br>  50%    254<br>  66%    257<br>  75%    261<br>  80%    262<br>  90%    264<br>  95%    267<br>  98%    267<br>  99%    269<br> 100%    269 (longest request)</pre><h3>Çıktıyı yorumlayalım;</h3><pre>Time taken for tests: 2.593 seconds</pre><p>Test toplam kaç saniye sürdü. Yani example.org adresi <strong>2.593</strong> saniyede 100 isteğe cevap vermiş.</p><pre>Failed requests: 0</pre><p>Başarısız olan istek sayısı, 0 gördüğünüz gibi.</p><pre>Requests per second: 38.56 [#/sec] (mean)</pre><p>saniyede yapılan istek sayısı, 38.56 istek yapılmış bir saniyede</p><pre>Time per request: 259.350 [ms] (mean)</pre><p>Bir istek kaç saniye sürmüş (ortalama), 259.350 milisaniye</p><pre>Time per request: 25.935 [ms] (mean, across all concurrent requests)</pre><p>Bir istek kaç saniye sürmüş (ortalama), 25.935 (eş zamanlı istekler dahil değil.)</p><p>Neden iki tane Time per request çıktısı var, çünkü birincisinde eşzamanlı istekler dahil hesaplanır, ikincisinde dahil değildir.</p><p>örneğin, ab -n 100 -c 1 example.org/ (dikkat edin, eş zamanlı istek yok) şeklinde bir test yaptığımızda iki değer de aynı çıkacaktır.</p><p>çok daha ayrıntılı bilgi için <a href="http://httpd.apache.org/docs/2.2/programs/ab.html">buraya</a> bakabilirsiniz.</p><p><em>Originally published at </em><a href="http://alioygur.github.io/test/2015/04/28/ab-test-araci/"><em>alioygur.github.io</em></a><em> on April 28, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=816479aaeefa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[go lang, tersine mühendislik, net/http]]></title>
            <link>https://alioygur.medium.com/go-lang-tersine-m%C3%BChendislik-net-http-44146e523210?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/44146e523210</guid>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Wed, 22 Apr 2015 00:00:00 GMT</pubDate>
            <atom:updated>2016-11-23T10:50:46.050Z</atom:updated>
            <content:encoded><![CDATA[<p>go lang, tersine mühendislik, net/http</p><p>bence bir şeyin nasıl çalıştığını öğrenmenin en iyi yolu, içini açıp bakmaktır. o yüzden bugün biz go dilinin en güçlü paketlerinden olan <strong>net/http</strong> paketini inceleyeceğiz.</p><p>bu paket, <strong>node.js</strong>‘in <a href="https://nodejs.org/api/http.html">http</a> paketine veya <strong>python</strong>‘un <a href="https://docs.python.org/2/library/httplib.html">httplib</a> paketine benzer. bununla güçlü bir web server oluşturabilir, gelen istekleri (request) leri yanıtlayabilirsiniz (response).</p><p>Öncelikle çok basit bir şekilde bu paketi nasıl kullanabileceğimize bakalım.</p><pre>package main<br><br>import (<br>    &quot;net/http&quot;<br>)<br><br>func IndexHandler(rw http.ResponseWriter, req *http.Request) {<br>    rw.Write([]byte(&quot;Hellow World!&quot;))<br>}<br>func main() {<br>    http.HandleFunc(&quot;/&quot;, IndexHandler)<br><br>    http.ListenAndServe(&quot;:8000&quot;, nil)<br>}</pre><p>Yukarıda 8000. portu dinleyen bir web server oluşturduk, “/” diye bir rota belirledik ve bu rotaya karşılık gelen bir fonksiyon atadık.</p><p>yukarıdaki kodu gon run dosyaadi şeklinde çalıştırdıktan sonra tarayıcımızdan <strong>http://localhost:8000</strong> yazdığımızda “Hello World” yazısı ile karşılacağız.</p><p>devam edecek…</p><p><em>Originally published at </em><a href="http://alioygur.github.io/go/2015/04/22/go-lang-tersine-muhendislik-net-http/"><em>alioygur.github.io</em></a><em> on April 22, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44146e523210" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang, pointer kavramı]]></title>
            <link>https://alioygur.medium.com/go-lang-pointer-kavram%C4%B1-a9bea994f1f2?source=rss-d0723f3d97ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9bea994f1f2</guid>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Ali UYGUR]]></dc:creator>
            <pubDate>Wed, 22 Apr 2015 00:00:00 GMT</pubDate>
            <atom:updated>2017-10-16T06:27:43.148Z</atom:updated>
            <content:encoded><![CDATA[<p>pointer yani işaretçiler, sadece go diline özel değildir, dinamik veya statik olsun çoğu dillerde vardır. örneğin PHP.</p><p>kod yazarken, tanımladığınız bütün değerler(değişkenler, sınıflar, vs.), bellek’te, “adı, değeri, ve adresi” şeklinde kabaca 3 sütün’da tutulur.</p><p>Pointer demek, bir değişkenin veya değerin bellek adresi demektir. bellek adresi “0x0000ffff” gibi, hexadecimal(onaltılık tabanda) bir değerdir.</p><p>Pointer’ların ne olduğu hakkında hiç bilgisi olmayanlar, <a href="http://tr.wikipedia.org/wiki/%C4%B0%C5%9Faret%C3%A7iler">wiki</a> sayfasına bakabilirler. zira biz pointer’ların kendisi ile değil de, go dilinde nasıl kullanabileceğimiz ile ilgileneceğiz.</p><p>pointer’ları kullanırken * ve &amp; karekterlerini sıkça kullanırız.</p><p>&amp; bize bir değerin bellek adresini döndürür. * ise tam tersidir. yani bir bellek adresinin değerini döndürür.</p><p>örnek ile görelim,</p><pre>package main<br><br>    import &quot;fmt&quot;<br><br>    <strong>var</strong> adi <strong>string</strong> = &quot;Ali&quot;<br>    <em>// buraya dikkat etmeniz gerekiyor. biz bu değişkenin tipini string değil de *string olarak</em><br>    <em>// belirttik. yani diyoruz ki, bu değişkenin değeri bir &quot;string değerin bellek adresi&quot; olacaktır.</em><br>    <strong>var</strong> adiPointer <strong>*string</strong> = <strong>&amp;</strong>adi<br><br>    <strong>func</strong> main() {<br>        fmt.Println(&quot;değişkenin değeri: &quot;, adi)<br>        fmt.Println(&quot;değişkenin bellek adresi: &quot;, adiPointer)<br>        fmt.Println(&quot;bellek adresinin değeri: &quot;, <strong>*</strong>adiPointer)<br><br>        <em>// iki değişken de arka planda aynı adresi işaret ettikleri için</em><br>        <em>// birini değiştirirseniz, diğeri de değişecektir.</em><br><br>        <strong>*</strong>adiPointer = &quot;Veli&quot;<br><br>        fmt.Println(&quot;adi değişkeninin değeri: &quot;, adi)<br>        fmt.Println(&quot;adiPointer değişkeninin değeri: &quot;, <strong>*</strong>adiPointer)<br>    }</pre><p>bu kodun çıktısı, aşağıdaki gibi’dir.</p><blockquote>değişkenin değeri: Ali</blockquote><blockquote>değişkenin bellek adresi: 0x1b4730</blockquote><blockquote>bellek adresinin değeri: Ali</blockquote><blockquote>adi değişkeninin değeri: Veli</blockquote><blockquote>adiPointer değişkeninin değeri: Veli</blockquote><p>inanmazsanız <a href="http://play.golang.org/p/MiCA-rbmQB">buradan</a> bakabilirsiniz :)</p><p><em>Originally published at </em><a href="http://alioygur.github.io/go/2015/04/22/go-lang-pointer-kavrami/"><em>alioygur.github.io</em></a><em> on April 22, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9bea994f1f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>