Showing entries 1 to 10 of 11
1 Older Entries »
Displaying posts with tag: golang (reset)
Writing MySQL proxy in GO for learning purposes: Part 2 — decoding connection phase server response

Writing MySQL Proxy in GO for self-learning: Part 2 — decoding handshake packet

After we built a generic TCP proxy, we can continue with our journey. Today’s goal will be to understand the MySQL Protocol, receive, decode, encode and send to the client the first packet sent by the MySQL Server.

MySQL connections threads

Each client connection to MySQL Server handled by a thread. MySQL is portable, so the underhood threads implementation is system dependent (Windows, macOS, and Linux have their own threads implementation).

What important to us, it’s to understand that a single client connection …

[Read more]
Quarantine Journey: Writing MySQL Proxy in GO for self-learning: Part 1 — TCP Proxy

Writing MySQL Proxy in GO for self-learning: Part 1 — TCP Proxy

Weekend. Quarantine. If you bored like me, and want to learn something new, you can join my journey of writing yet another MySQL Proxy Server.

In the past, I had a crazy idea of writing MySQL Proxy Server. The first reason was to understand the MySQL Communication Protocol to let me write more efficient programs. The second one was to learn more about low-level network programming concepts in general. Finally, I have time at least to start… and you can join me!

The real usage of MySQL Proxy can vary:

  • Testing and benchmarking of the infrastructure
  • Testing your applications for dealing with MySQL network failures and delays
  • Wrap the MySQL usage with own business layer
  • Load balancing
  • Multiplexing

Prelude

I’m not sure if I can …

[Read more]
How to Connect Golang with MySQL

Today, I will describe MySQL database connectivity with golang. MySQL is most popular open source relational database. I will let you know step by step how to golang connect with MySQL database. I assumed you have configured golang environment within your system, if not please configure golang environment into your system. The golang have MySQL […]

The post How to Connect Golang with MySQL appeared first on Phpflow.com.

New Stats Exposed in Go's database/SQL Package

If you’re someone who keeps up with the Go development cycle, then you’ll know that a couple of weeks ago Go entered its feature-freeze for the Go 1.11 release. One of the changes for this upcoming release that caught my eye was to the database/sql package. Daniel Theophanes contributed a change that introduces several new counters available via the DB.Stats() method.

If you’re not familiar with it, DB.Stats() returns a DBStat structure containing information about the underlying sql.DB that the method is called on. Up to this point, the struct has had a single field, tracking the current number of open connections to the database. Daniel’s patch introduces a number of …

[Read more]
New Stats Exposed in Go's database/SQL Package

If you’re someone who keeps up with the Go development cycle, then you’ll know that a couple of weeks ago Go entered its feature-freeze for the Go 1.11 release. One of the changes for this upcoming release that caught my eye was to the database/sql package. Daniel Theophanes contributed a change that introduces several new counters available via the DB.Stats() method.

If you’re not familiar with it, DB.Stats() returns a DBStat structure containing information about the underlying sql.DB that the method is called on. Up to this point, the struct has had a single field, tracking the current number of open connections to the database. Daniel’s patch introduces a number of …

[Read more]
How We Encrypt Data In MySQL With Go

A SaaS product needs to use security measures you might not ordinarily use in an on-premises solution. In particular, it’s important that all sensitive data be secured. Encryption plays an important role in information security. At VividCortex, we encrypt data in-flight and at-rest, so your sensitive data is never exposed.

We use Go and MySQL extensively at VividCortex and thought other Go programmers might be interested to see how we’ve integrated encryption into our services layer (APIs). (And if you'd like to learn more about programming with Go in general, please take a look at our free ebook The Ultimate Guide to Building Database-Driven Apps with Go.)


Image Source

Encryption Techniques …

[Read more]
How We Encrypt Data In MySQL With Go

A SaaS product needs to use security measures you might not ordinarily use in an on-premises solution. In particular, it’s important that all sensitive data be secured. Encryption plays an important role in information security. At VividCortex, we encrypt data in-flight and at-rest, so your sensitive data is never exposed.

We use Go and MySQL extensively at VividCortex and thought other Go programmers might be interested to see how we’ve integrated encryption into our services layer (APIs). (And if you'd like to learn more about programming with Go in general, please take a look at our free ebook The Ultimate Guide to Building Database-Driven Apps with Go.)


Image Source

Encryption Techniques …

[Read more]
Going for Go and Sticking with SQL

Why we’re switching from PHP to Go. Plus, why we’re happy with MySQL. LefT: ElePHPant (Vincent Pontier). Right: Gophers (golang.org).

At first, we thought that sticking with a familiar language was the responsible thing to do — we’re a small team, already engaged in two adventurous moves: a switch to microservices and a full rebuild of our legacy web application, a high-traffic game platform.

However, in the end we decided to go all the way and dropped PHP for Go. In this post we’ll explain why. We’ll also share some thoughts about databases within our microservices architecture.

Microservices and …

[Read more]
Common Pitfalls When Using database/sql in Go

Updated 3/23/2017

Here at VividCortex, we’re huge fans of the Go language and its database access library, database/sql. As you’ve probably seen firsthand, the surface area of database/sql is pretty small, but there’s a lot you can do with it. That includes plenty of risk for error and deceptive mistakes. This blog post is dedicated to some of the past mistakes we’ve made ourselves, in hopes that you won’t also make them when the time comes.



Image Credit


Common Pitfalls

  • Deferring inside a loop. A long-lived function with a query inside a loop, and defer rows.Close() inside the loop, will cause both memory and connection usage to grow without bounds.
[Read more]
A MySQL UDF written in Go

I was wondering if it is possible to write a MySQL User Defined Function (UDF) in Go.  
So I tried and I got a very basic UDF working.


mysql> SELECT udf_fileexists_go("/etc/hosts");
+---------------------------------+
| udf_fileexists_go("/etc/hosts") |
+---------------------------------+
| 1 |
+---------------------------------+
1 row in set (0.00 sec)

mysql> SELECT udf_fileexists_go("/nonexistend");
+-----------------------------------+
| udf_fileexists_go("/nonexistend") |
+-----------------------------------+
| 0 |
+-----------------------------------+
1 row in set (0.00 sec)


This is nowhere near production quality, so be careful.

The code is here: …

[Read more]
Showing entries 1 to 10 of 11
1 Older Entries »