Leipzig Gophers
blog

🔗Virtual Meetup #13 wrap-up

Today we had two input presentations:

Haystack

The haystack talk gave an overview about an early Facebook photo storage system and a Go project inspired by it, called seaweedfs. The seaweedfs project is great, as it is developer friendly, scales up and down and is easy to use out of the box. It offers an S3 compatible API and a FUSE filesystem option.

Functional Options Pattern

The Functional Options Pattern addresses API stability when it comes to configuration options. A simple way to configure a type is by passing in options directly (there can be too many), or by passing in a single config struct (which becomes part of the public API, for better or for worse). The functional options pattern works because in Go functions are first class values and can be passed as arguments into or returned by functions.

// WithInsecure skips certificate verification
func WithInsecure(in bool) ServerOption {
    return func(s *Server) error {
        if in {
            return errors.New("security alert")
        }
        s.insecure = in
        return nil
    }
}

The complete example can be found here: https://github.com/embano1/funcy-ops/blob/main/server.go.

Functional Options is a Go pattern and addresses some issues with too many arguments, variants of New and API stability.

Misc

Discussion evolved around testing (Go) code with controlled, restricted environments, like memory limits or maybe different ulimits. Running tests in containers can address these tasks (or one can get systemd to impose limits).

Furthermore, another way to embed files (there is a proposal from July 2020):

Book recommendation:

Go runtime interplay with containers and pods? Fasten your seatbelt: https://twitter.com/embano1/status/1149654812595646471

And finally, a few ideas that came up as topics for another talk:

Join us next time!


Image credit: Kobol