<?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 Pascal Allen on Medium]]></title>
        <description><![CDATA[Stories by Pascal Allen on Medium]]></description>
        <link>https://medium.com/@pascalallen?source=rss-90601cdad783------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mw5nFfFCUYb5x868mr-G3Q.png</url>
            <title>Stories by Pascal Allen on Medium</title>
            <link>https://medium.com/@pascalallen?source=rss-90601cdad783------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:23:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pascalallen/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[How To: Run a Go Web Server With Apple Container]]></title>
            <link>https://pascalallen.medium.com/how-to-run-a-go-web-server-with-apple-container-0fd1e7182b80?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fd1e7182b80</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Fri, 26 Jun 2026 20:08:11 GMT</pubDate>
            <atom:updated>2026-06-26T20:08:11.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4b3AnC2hqoasfrybBStxg.png" /></figure><p>In this publication, I will demonstrate how to build a small Go web server and run it with Apple’s container - a native containerization tool for macOS. The twist is that we will not install a Go toolchain on the host at all: building, running, and even running Go commands like tests all happen inside containers. This is a high-level tutorial for basic knowledge on the subject.</p><h3>Prerequisites</h3><ul><li><a href="https://github.com/apple/container">Apple </a><a href="https://github.com/apple/container">container</a></li></ul><p>container is Apple&#39;s open-source tool for building and running Linux containers natively on macOS, backed by lightweight virtual machines. It consumes standard OCI images, so an ordinary Dockerfile works without modification, and on Apple Silicon it targets arm64 by default.</p><h3>Project Initialization</h3><p>Let’s start by creating a new directory for our project along with the subdirectories we’ll need:</p><pre>mkdir cask \ <br>  &amp;&amp; cd cask \ <br>  &amp;&amp; mkdir -p cmd/server internal/config internal/handler bin</pre><p>Since we are not relying on a host Go toolchain, we’ll write the module file by hand. From the root of the project, create a file called go.mod and add the following:</p><pre>module github.com/pascalallen/cask <br><br>go 1.25.0 <br><br>require github.com/joho/godotenv v1.5.1</pre><p>cmd/server holds our entry point, internal/config and internal/handler hold our supporting packages, and bin will hold the helper scripts that wrap container.</p><h3>The Config Package</h3><p>cd into the internal/config directory and create a file called config.go and add the following code:</p><pre>package config<br><br>import (<br> &quot;os&quot;<br><br> &quot;github.com/joho/godotenv&quot;<br>)<br><br>type Config struct {<br> Port string<br>}<br><br>func Load() *Config {<br> _ = godotenv.Load()<br><br> port := os.Getenv(&quot;PORT&quot;)<br> if port == &quot;&quot; {<br>  port = &quot;8080&quot;<br> }<br><br> return &amp;Config{Port: port}<br>}</pre><p>This code loads a .env file if one is present and reads the PORT variable, falling back to 8080. Ignoring the godotenv.Load error is deliberate - a missing .env is normal inside a container, where configuration arrives through real environment variables.</p><h3>The Health Handler</h3><p>From the internal/handler directory, create a file called health.go and add the following code:</p><pre>package handler<br><br>import &quot;net/http&quot;<br><br>type HealthHandler struct{}<br><br>func NewHealthHandler() *HealthHandler {<br> return &amp;HealthHandler{}<br>}<br><br>func (h *HealthHandler) Handle(w http.ResponseWriter, r *http.Request) {<br> w.Header().Set(&quot;Content-Type&quot;, &quot;application/json&quot;)<br> w.WriteHeader(http.StatusOK)<br> _, _ = w.Write([]byte(`{&quot;status&quot;:&quot;ok&quot;}`))<br>}</pre><p>This code defines a single handler that responds to a health check with a 200 status and a small JSON body. We&#39;re using only the standard library here - for one route, net/http is all we need.</p><h3>The Entry Point</h3><p>Now let’s wire everything together. From the root of the project, cd into the cmd/server directory and create a file called main.go and add the following code:</p><pre>package main<br><br>import (<br> &quot;log&quot;<br> &quot;net/http&quot;<br><br> &quot;github.com/pascalallen/cask/internal/config&quot;<br> &quot;github.com/pascalallen/cask/internal/handler&quot;<br>)<br><br>func main() {<br> cfg := config.Load()<br><br> health := handler.NewHealthHandler()<br><br> mux := http.NewServeMux()<br> mux.HandleFunc(&quot;GET /health&quot;, health.Handle)<br><br> addr := &quot;:&quot; + cfg.Port<br> log.Printf(&quot;cask listening on %s&quot;, addr)<br> if err := http.ListenAndServe(addr, mux); err != nil {<br>  log.Fatalf(&quot;server error: %v&quot;, err)<br> }<br>}</pre><p>This code loads our config, constructs the handler, and registers it on a ServeMux using the Go 1.22+ method-aware pattern GET /health. There is no dependency injection framework here - for a project this size, plain constructor wiring is clearer.</p><h3>The Dockerfile</h3><p>container builds from a standard Dockerfile. From the root of the project, create a file called Dockerfile and add the following:</p><pre># syntax=docker/dockerfile:1<br><br># --- Builder stage ---------------------------------------------------------<br>FROM golang:1.25 AS builder<br><br>WORKDIR /src<br><br>COPY go.mod go.sum* ./<br>RUN go mod download<br><br>COPY . .<br><br>RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 \<br>    go build -trimpath -ldflags=&quot;-s -w&quot; -o /out/cask ./cmd/server<br><br># --- Runtime stage ---------------------------------------------------------<br>FROM gcr.io/distroless/static-debian12:nonroot<br><br>COPY --from=builder /out/cask /cask<br><br>EXPOSE 8080<br><br>ENTRYPOINT [&quot;/cask&quot;]</pre><p>This is a two-stage build. The first stage compiles a static, dependency-free binary targeting arm64. The second stage copies only that binary onto a minimal distroless base, which ships CA certificates and a non-root user without a shell or package manager.</p><h3>Helper Scripts</h3><p>The point of this project is that none of the Go work touches the host. Three small scripts in bin wrap the container CLI to make that comfortable.</p><p>From the bin directory, create a file called build and add the following:</p><pre>#!/usr/bin/env sh<br>set -e<br><br>ROOT=&quot;$(cd &quot;$(dirname &quot;$0&quot;)/..&quot; &amp;&amp; pwd)&quot;<br><br>cd &quot;$ROOT&quot;<br><br>container build --tag cask:latest --file Dockerfile .</pre><p>Next, create a file called run and add the following:</p><pre>#!/usr/bin/env sh<br>set -e<br><br>ROOT=&quot;$(cd &quot;$(dirname &quot;$0&quot;)/..&quot; &amp;&amp; pwd)&quot;<br><br>cd &quot;$ROOT&quot;<br><br>PORT=&quot;${PORT:-8080}&quot;<br><br>container run --rm --publish &quot;127.0.0.1:${PORT}:8080&quot; cask:latest</pre><p>Finally, create a file called go and add the following:</p><pre>#!/usr/bin/env sh<br>set -e<br><br>ROOT=&quot;$(cd &quot;$(dirname &quot;$0&quot;)/..&quot; &amp;&amp; pwd)&quot;<br>CACHE=&quot;${ROOT}/.cache&quot;<br>mkdir -p &quot;${CACHE}/gomod&quot; &quot;${CACHE}/gobuild&quot;<br><br>container run --rm \<br>  --volume &quot;${ROOT}:/app&quot; \<br>  --volume &quot;${CACHE}/gomod:/go/pkg/mod&quot; \<br>  --volume &quot;${CACHE}/gobuild:/root/.cache/go-build&quot; \<br>  --workdir /app \<br>  --env GOCACHE=/root/.cache/go-build \<br>  golang:1.25 \<br>  go &quot;$@&quot;</pre><p>build tags an image as cask:latest, and run publishes it on localhost. go is the interesting one: it bind-mounts the project into a golang container and runs go &quot;$@&quot;, so any Go command works without a local toolchain. The module and build caches are mounted under .cache so repeat runs stay fast.</p><p>Make all three executable:</p><pre>chmod +x bin/build bin/run bin/go</pre><h3>Installing Dependencies</h3><p>Our go.mod declares godotenv, but we still need a go.sum. Rather than reaching for a host toolchain, we let the container resolve it:</p><pre>./bin/go mod tidy</pre><p>This runs go mod tidy inside the golang image and writes go.sum back into the project through the bind mount.</p><h3>Building and Running the Container</h3><p>Build the image and start the container:</p><pre>./bin/build &amp;&amp; ./bin/run</pre><p>You should see output similar to the following:</p><pre>2025/01/01 00:00:00 cask listening on :8080</pre><p>From another terminal, hit the endpoint:</p><pre>curl http://localhost:8080/health</pre><p>You should get back:</p><pre>{&quot;status&quot;:&quot;ok&quot;}</pre><h3>Testing</h3><p>Tests run through the same container wrapper, so there’s still nothing to install locally:</p><pre>./bin/go test ./...</pre><p>For a coverage report, write it to a file and open it in your browser:</p><pre>./bin/go test ./... -covermode=count -coverprofile=coverage.out \ <br>  &amp;&amp; ./bin/go tool cover -html=coverage.out -o coverage.html \ <br>  &amp;&amp; open coverage.html</pre><h3>Conclusion</h3><p>In this publication, we built a minimal Go web server with a single health endpoint, packaged it as an OCI image, and built, ran, and tested it entirely through Apple’s container - without a Go toolchain on the host. The full source code is available at <a href="https://github.com/pascalallen/cask">https://github.com/pascalallen/cask</a>. For more on container itself, refer to the official documentation at <a href="https://github.com/apple/container">https://github.com/apple/container</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fd1e7182b80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event Sourcing in Go: A Full CQRS Implementation with EventStoreDB and RabbitMQ]]></title>
            <link>https://pascalallen.medium.com/event-sourcing-in-go-a-full-cqrs-implementation-with-eventstoredb-and-rabbitmq-1ac73782ef3a?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ac73782ef3a</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[event-sourcing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Tue, 26 May 2026 15:33:54 GMT</pubDate>
            <atom:updated>2026-05-26T15:33:54.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T2gBhGsKCqSs8T4N" /><figcaption>Photo by <a href="https://unsplash.com/@parsoakhorsand?utm_source=medium&amp;utm_medium=referral">Parsoa Khorsand</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What I Built</h3><p>A reference implementation of Event Sourcing (ES), Domain-Driven Design (DDD), and CQRS in Go. The domain is a User aggregate — simple enough to fit in one article, complex enough to surface every meaningful design constraint. The entire development environment runs in Docker.</p><p><strong>Stack:</strong></p><ul><li><strong>Go 1.26</strong> — the implementation language</li><li><strong>EventStoreDB</strong> — the event store (stream persistence, projections)</li><li><strong>RabbitMQ</strong> — async command dispatch via a persistent queue</li><li><strong>Google Wire</strong> — compile-time dependency injection</li></ul><p><strong>Directory layout:</strong></p><pre>cmd/es-go/               — entrypoint: wires the container, registers handlers, starts consumers<br>internal/es-go/<br>  domain/                — pure domain types; no infrastructure imports allowed here<br>    event/               — Event interface + all domain event structs<br>    user/                — User aggregate<br>    email/, password/,<br>    role/, permission/   — value objects<br>  application/<br>    command/             — command structs<br>    command_handler/     — one handler per command<br>    query/, query_handler/ — read side<br>    projection/          — JS projection scripts for EventStoreDB<br>  infrastructure/<br>    messaging/           — RabbitMQ command bus and synchronous query bus<br>    storage/             — EventStoreDB client wrapper</pre><p>The dependency rule is strict: domain/ imports nothing from application/ or infrastructure/. infrastructure/storage imports domain/event — never the reverse.</p><h3>The Domain Layer</h3><h4>The Event interface</h4><p>Every domain event implements a single interface:</p><pre>// internal/es-go/domain/event/event.go<br>type Event interface {<br> EventName() string<br>}</pre><p>One method. The concrete event structs carry all the data.</p><h4>Event structs</h4><pre>// internal/es-go/domain/event/user.go<br>type UserRegistered struct {<br> Id           ulid.ULID `json:&quot;id&quot;`<br> FirstName    string    `json:&quot;first_name&quot;`<br> LastName     string    `json:&quot;last_name&quot;`<br> EmailAddress string    `json:&quot;email_address&quot;`<br> PasswordHash string    `json:&quot;password_hash&quot;`<br> OccurredAt   time.Time `json:&quot;occurred_at&quot;`<br>}<br><br>func (e UserRegistered) EventName() string { return &quot;UserRegistered&quot; }</pre><p>Every event carries OccurredAt time.Time, set at raise-time. Deterministic replay never calls time.Now().</p><p>The other events follow the same pattern: UserEmailAddressUpdated, UserPasswordSet, UserRoleAssigned, UserDeleted.</p><h4>The User aggregate</h4><pre>// internal/es-go/domain/user/user.go<br>type User struct {<br> Id           ulid.ULID<br> FirstName    string<br> LastName     string<br> EmailAddress string<br> PasswordHash password.Hash<br> Roles        []role.Role<br> CreatedAt    time.Time<br> ModifiedAt   time.Time<br> DeletedAt    time.Time<br> version           int           // unexported<br> uncommittedEvents []event.Event // unexported<br>}</pre><p>version and uncommittedEvents are unexported — persistence plumbing is not part of the domain API.</p><h4>The factory</h4><pre>func Register(id ulid.ULID, firstName, lastName string, addr email.EmailAddress, hash password.Hash) (*User, error) {<br> if firstName == &quot;&quot; {<br>  return nil, fmt.Errorf(&quot;first name cannot be empty&quot;)<br> }<br> if lastName == &quot;&quot; {<br>  return nil, fmt.Errorf(&quot;last name cannot be empty&quot;)<br> }<br> u := &amp;User{version: -1}<br> u.raise(&amp;event.UserRegistered{<br>  Id:           id,<br>  FirstName:    firstName,<br>  LastName:     lastName,<br>  EmailAddress: addr.String(),<br>  PasswordHash: string(hash),<br>  OccurredAt:   time.Now(),<br> })<br> return u, nil<br>}</pre><p>version starts at -1. The factory does not set any fields directly; it raises a UserRegistered event and lets state mutation flow through the same path used during replay.</p><h4>Two paths, one state function</h4><p><strong>Write path (</strong><strong>raise)</strong> — called during a command:</p><pre>func (u *User) raise(evt event.Event) {<br> u.applyEventState(evt)<br> u.uncommittedEvents = append(u.uncommittedEvents, evt)<br> // version does NOT change here<br>}</pre><p><strong>Read path (</strong><strong>applyEvent)</strong> — called during replay:</p><pre>func (u *User) applyEvent(evt event.Event) {<br> u.applyEventState(evt)<br> u.version++ // only the read path increments version<br>}</pre><p>Both call the same applyEventState function:</p><pre>func (u *User) applyEventState(evt event.Event) {<br> switch e := evt.(type) {<br> case *event.UserRegistered:<br>  u.Id = e.Id<br>  u.FirstName = e.FirstName<br>  u.LastName = e.LastName<br>  u.EmailAddress = e.EmailAddress<br>  u.PasswordHash = password.Hash(e.PasswordHash)<br>  u.CreatedAt = e.OccurredAt<br> case *event.UserEmailAddressUpdated:<br>  u.EmailAddress = e.EmailAddress<br>  u.ModifiedAt = e.OccurredAt<br> case *event.UserPasswordSet:<br>  u.PasswordHash = password.Hash(e.PasswordHash)<br>  u.ModifiedAt = e.OccurredAt<br> case *event.UserRoleAssigned:<br>  u.Roles = append(u.Roles, e.Role)<br>  u.ModifiedAt = e.OccurredAt<br> case *event.UserDeleted:<br>  u.DeletedAt = e.OccurredAt<br> }<br>}</pre><h4>Rebuilding from history</h4><pre>func LoadUserFromEvents(events []event.Event) *User {<br> u := &amp;User{version: -1}<br> for _, evt := range events {<br>  u.applyEvent(evt)<br> }<br> return u<br>}</pre><p>version stays in sync with EventStoreDB’s 0-based stream revisions — no offset math. After replaying N events, version == N-1.</p><h3>Following a Command: RegisterUser</h3><h4>Dispatch</h4><p>CommandBus.Execute serializes the command and publishes it to the RabbitMQ commands queue:</p><pre>// infrastructure/messaging/command_bus.go<br>func (bus *RabbitMqCommandBus) Execute(cmd Command) error {<br> ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)<br> defer cancel()<br><br> b, err := json.Marshal(cmd)<br> if err != nil {<br>  return fmt.Errorf(&quot;failed to JSON encode command: %s&quot;, err)<br> }<br><br> err = bus.channel.PublishWithContext(ctx, &quot;&quot;, queueName, false, false,<br>  amqp091.Publishing{<br>   DeliveryMode: amqp091.Persistent,<br>   ContentType:  &quot;text/plain&quot;,<br>   Body:         b,<br>   Type:         cmd.CommandName(),<br>  },<br> )<br> if err != nil {<br>  return fmt.Errorf(&quot;failed to publish command: %s&quot;, err)<br> }<br><br> return nil<br>}</pre><p>DeliveryMode: amqp091.Persistent means the message survives a broker restart. The command name is set as the AMQP message type for routing on the consumer side.</p><h4>Consuming and dispatching</h4><p>StartConsuming runs in a goroutine. Each incoming message goes through processCommand:</p><pre>func (bus *RabbitMqCommandBus) processCommand(msg amqp091.Delivery) error {<br> var cmd Command<br><br> switch msg.Type {<br> case command.RegisterUser{}.CommandName():<br>  cmd = &amp;command.RegisterUser{}<br> case command.UpdateUserEmailAddress{}.CommandName():<br>  cmd = &amp;command.UpdateUserEmailAddress{}<br> case command.AssignRoleToUser{}.CommandName():<br>  cmd = &amp;command.AssignRoleToUser{}<br> case command.DeleteUser{}.CommandName():<br>  cmd = &amp;command.DeleteUser{}<br> default:<br>  return fmt.Errorf(&quot;unknown command received: %s&quot;, msg.Type)<br> }<br><br> err := json.Unmarshal(msg.Body, &amp;cmd)<br> if err != nil {<br>  return fmt.Errorf(&quot;failed to unmarshal command: %s&quot;, err)<br> }<br><br> handler, found := bus.handlers[cmd.CommandName()]<br> if !found {<br>  return fmt.Errorf(&quot;no handler registered for command type: %s&quot;, cmd.CommandName())<br> }<br><br> err = handler.Handle(cmd)<br> if err != nil {<br>  return fmt.Errorf(&quot;error calling command handler: %s&quot;, err)<br> }<br><br> err = msg.Ack(false)<br> if err != nil {<br>  return fmt.Errorf(&quot;error acknowledging command message: %s&quot;, err)<br> }<br><br> return nil<br>}</pre><p>The type switch couples the bus to application-layer command types. In a larger system you’d inject a map[string]func() Command registry to keep the bus generic — but for a reference implementation the coupling is explicit and readable.</p><h4>The handler</h4><p>RegisterUserHandler.Handle does the real work:</p><pre>// application/command_handler/user.go<br>func (h RegisterUserHandler) Handle(cmd messaging.Command) error {<br> c, ok := cmd.(*command.RegisterUser)<br> if !ok {<br>  return fmt.Errorf(&quot;invalid command type: %v&quot;, cmd)<br> }<br><br> // 1. Unique email check via EventStoreDB projection<br> var result ProjectionState<br> if err := h.EventStore.UnmarshalProjectionResult(&quot;user-email-addresses&quot;, &amp;result); err != nil {<br>  return fmt.Errorf(&quot;error getting projection result: %v&quot;, err)<br> }<br> for emailAddress := range result.EmailAddresses {<br>  if emailAddress == c.EmailAddress {<br>   return fmt.Errorf(&quot;email address %s is already registered&quot;, c.EmailAddress)<br>  }<br> }<br><br> // 2. Validate and construct value objects<br> addr, err := email.New(c.EmailAddress)<br> if err != nil {<br>  return fmt.Errorf(&quot;invalid email address: %w&quot;, err)<br> }<br> hash := password.Create(c.Password)<br><br> // 3. Create the aggregate — raises UserRegistered internally<br> u, err := user.Register(c.Id, c.FirstName, c.LastName, addr, hash)<br> if err != nil {<br>  return fmt.Errorf(&quot;could not register user: %w&quot;, err)<br> }<br><br> // 4. Persist<br> streamId := fmt.Sprintf(&quot;user-%s&quot;, c.Id)<br> if err := h.EventStore.AppendToStream(streamId, u.Version(), u.UncommittedEvents()); err != nil {<br>  return fmt.Errorf(&quot;could not store events: %w&quot;, err)<br> }<br> u.ClearUncommittedEvents()<br><br> return nil<br>}</pre><p>After user.Register returns, u.Version() is -1 and u.UncommittedEvents() contains one event: UserRegistered. The projections section covers the projection check (step 1) in detail.</p><h4>Persisting with optimistic concurrency</h4><pre>// infrastructure/storage/event_store.go<br>func (s *EventStoreDb) AppendToStream(streamId string, expectedVersion int, events []event.Event) error {<br> var opts esdb.AppendToStreamOptions<br> if expectedVersion == -1 {<br>  opts = esdb.AppendToStreamOptions{ExpectedRevision: esdb.NoStream{}}<br> } else {<br>  opts = esdb.AppendToStreamOptions{ExpectedRevision: esdb.Revision(uint64(expectedVersion))}<br> }<br><br> var eventDataSlice []esdb.EventData<br> for _, e := range events {<br>  data, err := json.Marshal(e)<br>  if err != nil {<br>   return fmt.Errorf(&quot;failed to marshal event %s: %s&quot;, e.EventName(), err)<br>  }<br>  eventDataSlice = append(eventDataSlice, esdb.EventData{<br>   ContentType: esdb.ContentTypeJson,<br>   EventType:   e.EventName(),<br>   Data:        data,<br>  })<br> }<br><br> _, err := s.client.AppendToStream(context.Background(), streamId, opts, eventDataSlice...)<br> if err != nil {<br>  return fmt.Errorf(&quot;failed to append events to stream: %s&quot;, err)<br> }<br><br> return nil<br>}</pre><p>The version-to-revision mapping:</p><ul><li>version == -1 → esdb.NoStream{} — asserts the stream does not yet exist. EventStoreDB rejects concurrent registration of the same user ID.</li><li>version &gt;= 0 → esdb.Revision(uint64(version)) — asserts the last persisted revision. EventStoreDB rejects concurrent modification since the last load.</li></ul><p>No read-before-write for new aggregates. The factory sets version = -1, and AppendToStream uses that directly.</p><h3>The Query Path</h3><p>Queries are synchronous — no queue. QueryBus.Fetch dispatches directly to the registered handler.</p><h4>The handler</h4><pre>// application/query_handler/user.go<br>func (h GetUserByIdHandler) Handle(qry messaging.Query) (any, error) {<br> q, ok := qry.(query.GetUserById)<br> if !ok {<br>  return nil, fmt.Errorf(&quot;invalid query type: %v&quot;, qry)<br> }<br><br> streamId := fmt.Sprintf(&quot;user-%s&quot;, q.Id)<br> events, err := h.EventStore.ReadFromStream(streamId)<br> if err != nil {<br>  return nil, fmt.Errorf(&quot;error reading events from stream: %s&quot;, err)<br> }<br><br> if len(events) == 0 {<br>  return nil, fmt.Errorf(&quot;no events found for user ID: %s&quot;, q.Id)<br> }<br><br> u := user.LoadUserFromEvents(events)<br> return u, nil<br>}</pre><p>Three steps: read the stream, check it’s non-empty, replay events into a fresh aggregate. The aggregate is always rebuilt from scratch — no snapshot, no cached state. The event log is the source of truth.</p><h4>Reading from EventStoreDB</h4><p>ReadFromStream pages through the stream in batches of 100:</p><pre>// infrastructure/storage/event_store.go<br>func (s *EventStoreDb) ReadFromStream(streamId string) ([]event.Event, error) {<br> var events []event.Event<br> position := esdb.Revision(0)<br><br> for {<br>  opts := esdb.ReadStreamOptions{From: position, Direction: esdb.Forwards}<br>  stream, err := s.client.ReadStream(context.Background(), streamId, opts, 100)<br>  // ...<br><br>  hasMoreEvents := false<br>  for {<br>   evt, err := stream.Recv()<br>   if err != nil {<br>    if errors.Is(err, io.EOF) { break }<br>    // ...<br>   }<br><br>   var e event.Event<br>   switch evt.OriginalEvent().EventType {<br>   case event.UserRegistered{}.EventName():<br>    e = &amp;event.UserRegistered{}<br>   case event.UserEmailAddressUpdated{}.EventName():<br>    e = &amp;event.UserEmailAddressUpdated{}<br>   case event.UserPasswordSet{}.EventName():<br>    e = &amp;event.UserPasswordSet{}<br>   case event.UserRoleAssigned{}.EventName():<br>    e = &amp;event.UserRoleAssigned{}<br>   case event.UserDeleted{}.EventName():<br>    e = &amp;event.UserDeleted{}<br>   }<br><br>   if err = json.Unmarshal(evt.OriginalEvent().Data, e); err != nil { ... }<br>   events = append(events, e)<br>   position = esdb.Revision(evt.OriginalEvent().EventNumber + 1)<br>   hasMoreEvents = true<br>  }<br>  stream.Close()<br>  if !hasMoreEvents { break }<br> }<br><br> return events, nil<br>}</pre><p>The type switch exists because Go’s json.Unmarshal requires a concrete type. The switch maps EventStoreDB’s event type strings back to Go structs; JSON does the rest. The loop continues until a batch comes back empty.</p><p>After ReadFromStream returns, LoadUserFromEvents replays the slice through the same applyEvent loop defined in the Domain Layer section — same version increment, same applyEventState switch. The aggregate reflects the full history of the stream.</p><h3>Projections for Cross-Aggregate Queries</h3><p>The unique email constraint requires knowing all registered email addresses across all User streams. There’s no SQL table to query. The answer is an EventStoreDB projection.</p><h4>The projection</h4><pre>// application/projection/user.go<br>type UserEmailAddresses struct{}<br><br>func (p UserEmailAddresses) Name() string { return &quot;user-email-addresses&quot; }<br><br>func (p UserEmailAddresses) Script() string {<br> return `fromCategory(&#39;user&#39;)<br>.when({<br>    $init: function () {<br>        return { email_addresses: {} };<br>    },<br>    UserRegistered: function (state, event) {<br>        state.email_addresses[event.data.email_address] = event.data.id;<br>    },<br>    UserEmailAddressUpdated: function (state, event) {<br>        for (let emailAddress in state.email_addresses) {<br>            if (state.email_addresses[emailAddress] === event.data.id) {<br>                delete state.email_addresses[emailAddress];<br>                break;<br>            }<br>        }<br>        state.email_addresses[event.data.email_address] = event.data.id;<br>    }<br>})<br>.outputState();`</pre><p>This JavaScript runs server-side inside EventStoreDB. fromCategory(‘user’) subscribes to all streams prefixed with user-. $init returns the initial state object. UserRegistered adds an email → id mapping; UserEmailAddressUpdated removes the old entry and adds the new one. .outputState() makes the accumulated state queryable.</p><h4>Registration</h4><p>main.go registers the projection at startup:</p><pre>// main.go<br>eventStore.RegisterProjection(projection.UserEmailAddresses{})</pre><p>RegisterProjection calls the EventStoreDB Projections API to create it. RegisterProjection ignores a conflict error (“already exists”) — the projection survives restarts without duplication.</p><h4>Querying the result</h4><p>The command handler pulls the projection state back into Go before validating:</p><pre>var result ProjectionState<br>h.EventStore.UnmarshalProjectionResult(&quot;user-email-addresses&quot;, &amp;result)<br>for emailAddress := range result.EmailAddresses {<br> if emailAddress == c.EmailAddress {<br>  return fmt.Errorf(&quot;email address %s is already registered&quot;, c.EmailAddress)<br> }<br>}</pre><p>UnmarshalProjectionResult calls the EventStoreDB Projections API, gets the JSON result, and unmarshals it into ProjectionState — a struct with an EmailAddresses map[string]string field.</p><p>Instead of a separate Redis cache or Postgres read table, the projection state lives inside EventStoreDB. Fewer moving parts. The trade-off: projection logic is limited to EventStoreDB’s JavaScript engine, and results are eventually consistent with the event stream.</p><h3>Dependency Injection with Wire</h3><h4>The container</h4><pre>// cmd/es-go/container.go<br>type Container struct {<br> EventStore             storage.EventStore<br> MessageQueueConnection *amqp091.Connection<br> CommandBus             messaging.CommandBus<br> QueryBus               messaging.QueryBus<br>}</pre><p>A plain struct — no framework magic, no reflection at runtime.</p><h4>The injector</h4><p>The //go:build wireinject tag excludes wire.go from normal builds:</p><pre>// cmd/es-go/wire.go<br>//go:build wireinject<br>// +build wireinject<br><br>package main<br><br>import (<br> &quot;github.com/google/wire&quot;<br> &quot;github.com/pascalallen/es-go/internal/es-go/infrastructure/messaging&quot;<br> &quot;github.com/pascalallen/es-go/internal/es-go/infrastructure/storage&quot;<br>)<br><br>func InitializeContainer() Container {<br> wire.Build(<br>  NewContainer,<br>  storage.NewEventStoreDb,<br>  messaging.NewRabbitMQConnection,<br>  messaging.NewRabbitMqCommandBus,<br>  messaging.NewSynchronousQueryBus,<br> )<br> return Container{}<br>}</pre><p>wire.Build takes a list of provider functions. Wire resolves the dependency graph by matching each function’s parameter types to another provider’s return type. The generated wire_gen.go is the actual InitializeContainer implementation — readable Go, no reflection.</p><p>Why Wire over a DI container library: dependency errors are compile-time failures, not runtime panics. To regenerate after adding a provider:</p><pre>bin/exec wire</pre><h3>Closing</h3><p>This codebase is a reference implementation — deliberately minimal so the patterns stay visible. There’s no HTTP layer, no authentication middleware, no retry logic. What it does have is a complete, runnable ES/DDD/CQRS stack in Go where every design decision has a clear reason.</p><p>Things that I’d like to start exploring next:</p><ul><li><strong>Snapshotting</strong>— for aggregates with long histories, cache a point-in-time state to avoid replaying from event 0 on every read</li><li><strong>Multiple aggregates</strong> — introduce an Order or Account aggregate and see how cross-aggregate consistency works without shared tables</li><li><strong>Read API</strong> — add an HTTP layer; the query bus is synchronous and ready</li></ul><p>The full source is at <a href="https://github.com/pascalallen/es-go">https://github.com/pascalallen/es-go</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ac73782ef3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Turned a $35 Computer Into a Live Security Camera With Go]]></title>
            <link>https://pascalallen.medium.com/i-turned-a-35-computer-into-a-live-security-camera-with-go-f1e061dacc33?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1e061dacc33</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Fri, 22 May 2026 19:02:29 GMT</pubDate>
            <atom:updated>2026-05-22T19:02:29.413Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been meaning to add a security camera to my setup for a while. Not a Ring. Not a Nest. Not anything that wants my credit card every month or stores my footage on someone else’s server. I just wanted to point a camera at something and see it in my browser. That’s it.</p><p>As it turns out, a Raspberry Pi and a camera module is all you need. The rest is software — and the software is more interesting than you’d expect.</p><h3>The Hardware</h3><p>A Raspberry Pi is a credit-card-sized single-board computer that runs Linux. You can run a full operating system on it, write and execute code, connect peripherals, and — most importantly for our purposes — attach a camera module.</p><p>The camera module connects directly to the Pi’s CSI (Camera Serial Interface) port. One cable. No drivers to install manually. The Pi’s libcamera stack handles everything.</p><p>That’s the entire hardware story. The two components together cost under $100.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lv5IosbxIm7zkGxX_SYdWw.jpeg" /><figcaption>Hardware setup</figcaption></figure><h3>Streaming Video Sounds Simple Until It Isn’t</h3><p>I want to open a browser tab and see live video from the camera. Simple enough, right?</p><p>Here’s where it gets interesting. There are a few ways to stream video from a camera to a browser, and most of them are more complicated than you’d expect:</p><ul><li><strong>WebRTC</strong> — Powerful, but it’s a peer-to-peer protocol designed for low-latency communication between browsers. Setting up a signaling server and managing ICE candidates for a one-way camera feed is serious overkill.</li><li><strong>WebSockets + encoding</strong> — You could encode frames on the server and push them over a WebSocket, but now you’re writing a custom JavaScript player to decode them.</li></ul><p>So what does a browser already know how to display? It turns out: <strong>MJPEG</strong>.</p><p>MJPEG (Motion JPEG) is a format where individual JPEG frames are delivered in sequence over a single HTTP connection, separated by multipart boundaries. Browsers have supported it natively for decades. No JavaScript. No decoder. Just an &lt;img&gt; tag pointing at the stream endpoint, and the browser does the rest.</p><pre>&lt;img src=&quot;/stream&quot; alt=&quot;camera feed&quot;&gt;</pre><p>That’s the entire frontend.</p><h3>Enter GStreamer</h3><p>GStreamer is an open-source multimedia pipeline framework. You describe a chain of processing elements — a “pipeline” — and GStreamer handles moving data through them.</p><p>The Pi’s camera stack uses libcamera as its hardware abstraction layer. GStreamer has a libcamera source element, which means I can plug directly into the camera with no extra code.</p><p>Here’s the pipeline:</p><pre>gst-launch-1.0 -q \<br>  libcamerasrc \<br>  ! video/x-raw,format=NV12,width=1280,height=720,framerate=15/1 \<br>  ! videoconvert \<br>  ! jpegenc quality=75 \<br>  ! multipartmux boundary=frame \<br>  ! fdsink fd=1</pre><p>Reading left to right:</p><ol><li>libcamerasrc — raw frames from the camera</li><li>video/x-raw,format=NV12,… — negotiate NV12 color format at 1280×720, 15fps</li><li>videoconvert — normalize the color space</li><li>jpegenc quality=75 — encode each frame as a JPEG</li><li>multipartmux boundary=frame — wrap frames in MJPEG multipart format</li><li>fdsink fd=1 — write to stdout</li></ol><p>The last part is the key. By writing to stdout, Go can read the MJPEG stream directly from the process — no temp files, no sockets, no shared memory.</p><h3>The Hub: One Camera, Many Viewers</h3><p>Here’s a problem worth solving: what happens when multiple browser tabs open the stream at the same time?</p><p>You don’t want to run a separate GStreamer process for each viewer. That would be wasteful and would cause the camera to be initialized multiple times (which libcamera does not appreciate).</p><p>The solution is a <strong>fan-out pub/sub hub</strong>. One GStreamer process produces frames. The hub distributes those frames to every connected viewer.</p><p>When a viewer connects to /stream, they call Subscribe(), which registers a buffered channel for them. When a frame arrives from GStreamer, broadcast() sends a copy of it to every subscriber’s channel. When a viewer disconnects, Unsubscribe() removes their channel from the map.</p><pre>func (h *Hub) broadcast(p []byte) {<br> chunk := make([]byte, len(p))<br> copy(chunk, p)<br> h.mu.Lock()<br> for ch := range h.subs {<br>  select {<br>  case ch &lt;- chunk:<br>  default: // slow subscriber: drop chunk rather than stall others<br>  }<br> }<br> h.mu.Unlock()<br>}</pre><p>That default case is doing important work. If a subscriber’s channel buffer is full — because they’re on a slow connection and can’t keep up — their frame gets dropped instead of blocking the broadcast. One laggy client doesn’t ruin everyone else’s stream.</p><p>Each subscriber channel has a buffer capacity of 30 frames. At 15fps, that’s about two seconds of tolerance for network jitter before drops begin.</p><h3>The Clever Bits</h3><p>A few implementation decisions worth calling out:</p><ol><li><strong>Self-contained binary with </strong><strong>//go:embed</strong></li></ol><pre>//go:embed index.html<br>var indexHTML []byte</pre><p>The HTML viewer is compiled directly into the Go binary. No web server configuration, no static file directory to manage. The binary is the entire application.</p><p>2. <strong>Lazy GStreamer startup with </strong><strong>sync.Once</strong></p><p>GStreamer only starts when the first viewer connects. If nobody is watching, the camera isn’t running. This is sync.Once doing exactly what it’s designed for — initialize on first use, never again.</p><p>3. <strong>Auto-restart on crash</strong></p><pre>func (h *Hub) loop() {<br> for {<br>  h.runGStreamer()<br>  time.Sleep(time.Second)<br> }<br>}</pre><p>If GStreamer crashes — and pipelines occasionally do — it restarts automatically after a one-second delay. Simple and effective.</p><p>4.<strong> Zero external Go dependencies</strong></p><p>The entire Go codebase uses only the standard library: net/http, os/exec, sync, bytes, log, time. Nothing to vendor, nothing to update, nothing to audit.</p><h3>Packaging It With Docker</h3><p>The one wrinkle in containerizing this is the Raspberry Pi’s camera stack. The gstreamer1.0-libcamera package and libcamera-ipa aren’t in the standard Debian package archive — they come from the Raspberry Pi Foundation’s own apt repository.</p><p>The Dockerfile adds that repository before installing packages:</p><pre>RUN curl -fsSL https://archive.raspberrypi.com/debian/raspberrypi.gpg.key \<br>       | gpg --dearmor -o /etc/apt/trusted.gpg.d/raspberrypi.gpg \<br>    &amp;&amp; echo &quot;deb http://archive.raspberrypi.com/debian/ bookworm main&quot; \<br>       &gt; /etc/apt/sources.list.d/raspi.list</pre><p>The Docker Compose configuration handles device passthrough — giving the container access to the camera hardware:</p><pre>devices:<br>  - /dev/video0:/dev/video0<br>  - /dev/media0:/dev/media0<br>volumes:<br>  - /run/udev:/run/udev:ro</pre><p>With that in place:</p><pre>docker compose up -d --build</pre><p>Open <a href="http://localhost:8080`">http://localhost:8080</a> and you’re live.</p><h3>The Result</h3><p>About 170 lines of Go, zero external dependencies, one Raspberry Pi, one camera module — and live video in any browser tab. Open five tabs. They all work. One GStreamer process, one camera, five viewers.</p><p>The full source is on GitHub: <a href="https://github.com/pascalallen/rpi-security-cam">https://github.com/pascalallen/rpi-security-cam</a></p><p>Thanks for reading! I hope this was informative. My goal is to share and teach in a fundamentally succinct format. Have a great day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1e061dacc33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Structuring Go Projects With Clean Architecture]]></title>
            <link>https://pascalallen.medium.com/structuring-go-projects-with-clean-architecture-2c46d7e58ac3?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c46d7e58ac3</guid>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Wed, 20 May 2026 22:42:02 GMT</pubDate>
            <atom:updated>2026-05-20T23:05:16.595Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KkSYQbQ4AYLGFquX" /><figcaption>Photo by <a href="https://unsplash.com/@amsterdamcityarchives?utm_source=medium&amp;utm_medium=referral">Amsterdam City Archives</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this publication, I will walk through how I structure my Go projects. This is a high-level overview of the patterns and conventions I rely on, illustrated with real code from <a href="https://github.com/pascalallen/go-clean-arch">go-clean-arch</a> — a companion repository that demonstrates this structure end-to-end.</p><p>Go gives you very little opinion about how to organize your code. That freedom is one of its strengths, but it can also be a source of confusion, especially as a project grows. Over time I’ve settled on a structure that keeps business logic clean, separates concerns clearly, and makes the codebase easy to navigate and extend.</p><h3>Project Structure</h3><p>Every Go project I build starts from the same top-level layout:</p><pre>├── bin/       # Helper CLI scripts<br>├── cmd/       # Go main packages (entry points)<br>├── docs/      # Documentation<br>├── internal/  # All application code<br>└── web/       # Frontend assets</pre><p>cmd/ holds one or more main packages — the entry points for the application and any supporting tools like database seeders. internal/ is where everything else lives, scoped so that no outside package can import it directly. web/ contains frontend assets compiled separately from the Go binary.</p><h3>The Domain Layer</h3><p>Inside internal/, I organize code around three layers. The innermost is the domain layer.</p><pre>internal/<br>└── app/<br>    └── domain/<br>        ├── user/<br>        │   ├── user.go<br>        │   └── repository.go<br>        ├── role/<br>        ├── permission/<br>        └── ...</pre><p>Domain packages contain the core business logic of the application — entities, repository interfaces, and service interfaces. There are no framework imports here. A User entity looks like this:</p><pre>type User struct {<br>    Id           ulid.ULID<br>    FirstName    string<br>    LastName     string<br>    EmailAddress string<br>    PasswordHash password.PasswordHash<br>    Roles        []role.Role<br>    CreatedAt    time.Time<br>    ModifiedAt   *time.Time<br>}<br><br>func Register(id ulid.ULID, firstName, lastName, emailAddress string) *User {<br>    return &amp;User{<br>        Id:           id,<br>        FirstName:    firstName,<br>        LastName:     lastName,<br>        EmailAddress: emailAddress,<br>        CreatedAt:    time.Now(),<br>    }<br>}</pre><p>Entities carry behavior — methods like AddRole and HasPermission— rather than just holding data. Repository interfaces live alongside the entity they belong to:</p><pre>type Repository interface {<br>    GetById(id ulid.ULID) (*User, error)<br>    GetByEmailAddress(emailAddress string) (*User, error)<br>    Add(user *User) error<br>    Remove(user *User) error<br>    Save(user *User) error<br>}</pre><p>The domain layer defines the contract. It never cares how or where data is stored.</p><h3>The Application Layer</h3><p>The application layer sits above the domain and orchestrates it. This is where I apply CQRS — Command Query Responsibility Segregation.</p><pre>application/<br>├── command/<br>├── command_handler/<br>├── event/<br>├── listener/<br>├── query/<br>└── query_handler/</pre><p>Commands express intent. They are simple structs:</p><pre>type RegisterUser struct {<br>    Id           ulid.ULID<br>    FirstName    string<br>    LastName     string<br>    EmailAddress string<br>}<br><br>func (c RegisterUser) CommandName() string {<br>    return &quot;RegisterUser&quot;<br>}</pre><p>Command handlers do the actual work — fetching dependencies, calling domain methods, persisting changes, and dispatching events:</p><pre>func (h RegisterUserHandler) Handle(cmd messaging.Command) error {<br>    c := cmd.(*command.RegisterUser)<br><br>    u := user.Register(c.Id, c.FirstName, c.LastName, c.EmailAddress)<br>    h.UserRepository.Add(u)<br><br>    h.EventDispatcher.Dispatch(&amp;event.UserRegistered{<br>        Id:           c.Id,<br>        EmailAddress: c.EmailAddress,<br>    })<br><br>    return nil<br>}</pre><p>Queries follow the same shape but on the read side: a ListUsers query, a ListUsersHandler that fetches and returns data. Reads and writes never share a handler.</p><p>Events and listeners decouple side effects. When a user registers, a UserRegistered event is dispatched. A separate listener picks it up and handles any post-registration logic. The registration handler has no knowledge of what happens after the event is dispatched.</p><h3>The Infrastructure Layer</h3><p>The infrastructure layer provides concrete implementations of everything the domain and application layers define.</p><pre>infrastructure/<br>├── container/<br>├── database/<br>├── messaging/<br>├── repository/<br>├── routes/<br>├── service/<br>└── websocket/</pre><p>Repository implementations live here. They talk to Postgres using raw SQL — no ORM:</p><pre>type PostgresUserRepository struct {<br>    session *sql.DB<br>    logger  logger.Logger<br>}<br><br>func (r *PostgresUserRepository) GetById(id ulid.ULID) (*user.User, error) {<br>    q := `SELECT id, first_name, last_name, email_address, ...<br>          FROM users WHERE id = $1`<br><br>    row := r.session.QueryRow(q, id.String())<br>    // scan and load roles...<br>    return &amp;u, nil<br>}</pre><p>The messaging package provides three buses:</p><ul><li>ChannelCommandBus — asynchronous, backed by a buffered Go channel. Commands are enqueued and processed in a goroutine.</li><li>ChannelEventDispatcher — same pattern, for events and their listeners.</li><li>SynchronousQueryBus — synchronous, because queries need to return data immediately.</li></ul><pre>func (bus *ChannelCommandBus) Execute(cmd Command) error {<br>    bus.ch &lt;- cmd<br>    return nil<br>}<br><br>func (bus *ChannelCommandBus) StartConsuming() {<br>    for cmd := range bus.ch {<br>        bus.processCommand(cmd)<br>    }<br>}</pre><p>The routes/ package defines HTTP handlers using Gin, and the websocket/ package manages a real-time hub for push updates to connected clients.</p><h3>Wiring It All Together</h3><p>With this many moving parts, dependency injection becomes important. I use <a href="https://github.com/google/wire">Google Wire</a> to generate the wiring automatically.</p><p>All dependencies are declared in a Container struct:</p><pre>type Container struct {<br>    DatabaseSession      *sql.DB<br>    Logger               logger.Logger<br>    PermissionRepository permission.Repository<br>    RoleRepository       role.Repository<br>    UserRepository       user.Repository<br>    CommandBus           messaging.CommandBus<br>    QueryBus             messaging.QueryBus<br>    EventDispatcher      messaging.EventDispatcher<br>    WebsocketHub         *websocket.Hub<br>}</pre><p>Wire generates an InitializeContainer() function that builds the full dependency graph from a set of provider functions:</p><pre>func InitializeContainer() Container {<br>    wire.Build(<br>        NewContainer,<br>        slog.New,<br>        database.NewPostgresSession,<br>        repository.NewPostgresPermissionRepository,<br>        repository.NewPostgresRoleRepository,<br>        repository.NewPostgresUserRepository,<br>        messaging.NewChannelCommandBus,<br>        messaging.NewSynchronousQueryBus,<br>        messaging.NewChannelEventDispatcher,<br>        websocket.NewHub,<br>    )<br>    return Container{}<br>}</pre><p>At startup, main.go calls InitializeContainer() once and passes the result everywhere it’s needed. No globals. No init functions. No hidden state.</p><h3>The Dev Environment</h3><p>Local development runs entirely in Docker Compose:</p><pre>services:<br>  postgres:<br>    build:<br>      context: internal/app/infrastructure/etc/postgres<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB&quot;]<br><br>  go:<br>    build:<br>      context: .<br>    depends_on:<br>      postgres:<br>        condition: service_healthy</pre><p>On startup, the application automatically runs all pending database migrations using <a href="https://github.com/golang-migrate/migrate">golang-migrate</a> and seeds reference data. There is no manual setup step once the environment is up.</p><p>Helper scripts in bin/ wrap the most common Docker commands so the development workflow stays consistent across machines.</p><h3>Conclusion</h3><p>In this publication, we walked through how I structure Go projects: a domain layer for core business logic and repository interfaces, an application layer for CQRS commands, queries, and event-driven listeners, and an infrastructure layer for the concrete implementations. Google Wire handles dependency injection, and Docker Compose handles the local environment. The full source code is available at <a href="https://github.com/pascalallen/go-clean-arch](https://github.com/pascalallen/go-clean-arch).">https://github.com/pascalallen/go-clean-arch.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c46d7e58ac3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To: Build an MCP Server In Go]]></title>
            <link>https://pascalallen.medium.com/how-to-build-an-mcp-server-in-go-50ed8a4c9ed4?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/50ed8a4c9ed4</guid>
            <category><![CDATA[model-context-protocol]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Fri, 15 May 2026 20:55:01 GMT</pubDate>
            <atom:updated>2026-05-15T20:55:01.066Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*QdLSe6TaSxSpjjzE-o6lsw.png" /></figure><p>In this publication, I will demonstrate how to build an MCP server in Go and install it for use with an AI client such as Claude Code. This is a high-level tutorial for basic knowledge on the subject.</p><h3>Prerequisites</h3><ul><li><a href="https://go.dev/dl/">Go</a></li></ul><blockquote><a href="https://modelcontextprotocol.io/docs/getting-started/intro">MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems.</a></blockquote><h3>Project Initialization</h3><p>Let’s start by creating a new directory for our project, initialize our Go module, and pull in the two libraries our server will depend on:</p><pre>mkdir mcp-server-go/ \<br>  &amp;&amp; cd mcp-server-go \<br>  &amp;&amp; go mod init github.com/pascalallen/mcp-server-go \<br>  &amp;&amp; go get github.com/mark3labs/mcp-go \<br>  &amp;&amp; go get github.com/gin-gonic/gin</pre><p>mcp-go is a Go SDK for building MCP servers, and gin is a popular, well-maintained HTTP web framework for Go.</p><p>Now from the root of the project, let’s create a few subdirectories:</p><pre>mkdir cmd/ internal/ \<br>  &amp;&amp; cd internal/ \<br>  &amp;&amp; mkdir mcp/ routes/</pre><p>These subdirectories will contain our Go MCP server, MCP services, and HTTP routes.</p><h3>MCP Service</h3><p>Now from the internal/mcp/ directory, create a file called tools.go and add the following code:</p><pre>package mcp<br><br>import (<br> &quot;context&quot;<br> &quot;fmt&quot;<br> &quot;time&quot;<br><br> mcpgo &quot;github.com/mark3labs/mcp-go/mcp&quot;<br>)<br><br>const Version = &quot;0.1.0&quot;<br><br>var startTime = time.Now()<br><br>func HandleEcho(_ context.Context, req mcpgo.CallToolRequest) (*mcpgo.CallToolResult, error) {<br> args := req.GetArguments()<br> msg, ok := args[&quot;message&quot;].(string)<br> if !ok || msg == &quot;&quot; {<br>  return nil, fmt.Errorf(&quot;message argument is required and must be a string&quot;)<br> }<br> return mcpgo.NewToolResultText(msg), nil<br>}<br><br>func HandleServerInfo(_ context.Context, _ mcpgo.CallToolRequest) (*mcpgo.CallToolResult, error) {<br> uptime := time.Since(startTime).Round(time.Second)<br> info := fmt.Sprintf(`{&quot;name&quot;:&quot;mcp-server-go&quot;,&quot;version&quot;:%q,&quot;uptime_seconds&quot;:%d}`, Version, int(uptime.Seconds()))<br> return mcpgo.NewToolResultText(info), nil<br>}</pre><p>This code defines two handlers for the two tools that we will be adding to our MCP service. HandleEcho returns a given message, and HandleServerInfo returns arbitrary server info.</p><p>Now from the same internal/mcp/ directory, create a file called server.go and add the following code:</p><pre>package mcp<br><br>import (<br> &quot;net/http&quot;<br><br> mcpgo &quot;github.com/mark3labs/mcp-go/mcp&quot;<br> &quot;github.com/mark3labs/mcp-go/server&quot;<br>)<br><br>func NewServer() http.Handler {<br> s := server.NewMCPServer(<br>  &quot;mcp-server-go&quot;,<br>  Version,<br>  server.WithToolCapabilities(true),<br> )<br><br> echoTool := mcpgo.NewTool(<br>  &quot;echo&quot;,<br>  mcpgo.WithDescription(&quot;Returns the input message unchanged. Useful for testing connectivity.&quot;),<br>  mcpgo.WithString(<br>   &quot;message&quot;,<br>   mcpgo.Required(),<br>   mcpgo.Description(&quot;The message to echo back&quot;),<br>  ),<br> )<br> s.AddTool(echoTool, HandleEcho)<br><br> serverInfoTool := mcpgo.NewTool(<br>  &quot;server_info&quot;,<br>  mcpgo.WithDescription(&quot;Returns server name, version, and uptime in seconds.&quot;),<br> )<br> s.AddTool(serverInfoTool, HandleServerInfo)<br><br> return server.NewStreamableHTTPServer(s)<br>}</pre><p>This code defines a constructor function for our MCP server that registers the tools we want to expose and returns a streamable HTTP handler.</p><h3>HTTP Service</h3><p>Now that we have an MCP handler, let’s build the HTTP layer. cd into the internal/routes/ directory and create a file called routes.go and add the following code:</p><pre>package routes<br><br>import (<br> &quot;log&quot;<br> &quot;net/http&quot;<br><br> &quot;github.com/gin-gonic/gin&quot;<br>)<br><br>type Router struct {<br> engine *gin.Engine<br>}<br><br>func NewRouter(mcpHandler http.Handler) Router {<br> r := gin.Default()<br> r.Any(&quot;/mcp&quot;, gin.WrapH(mcpHandler))<br> return Router{engine: r}<br>}<br><br>func (r Router) Serve(addr string) {<br> if err := r.engine.Run(addr); err != nil {<br>  log.Fatalf(&quot;server: %v&quot;, err)<br> }<br>}</pre><p>This code defines a router that maps all request methods on /mcp to our MCP handler. gin.WrapH adapts the standard http.Handler to work with gin’s routing layer.</p><h3><strong>Entry Point</strong></h3><p>Now let’s wire everything together. From the root of the project, cd into the cmd/ directory and create a file called main.go and add the following code:</p><pre>  package main<br><br>  import (<br>      &quot;log&quot;<br><br>      inframcp &quot;github.com/pascalallen/mcp-server-go/internal/mcp&quot;<br>      &quot;github.com/pascalallen/mcp-server-go/internal/routes&quot;<br>  )<br>  <br>  func main() {<br>      mcpHandler := inframcp.NewServer()<br>      log.Println(&quot;starting mcp-server-go on :8080&quot;)<br>      routes.NewRouter(mcpHandler).Serve(&quot;:8080&quot;)<br>  }</pre><p>This initializes the MCP server, passes the handler to our router, and starts listening on port 8080.</p><h3><strong>Running the Server</strong></h3><p>From the root of the project, run the following:</p><pre>go mod tidy &amp;&amp; go run cmd/main.go</pre><p>You should see output similar to the following:</p><pre>2025/01/01 00:00:00 starting mcp-server-go on :8080<br>[GIN-debug] Listening and serving HTTP on :8080</pre><h3><strong>Installing for Claude Code</strong></h3><p>With the server running, open a new terminal session and install it as an MCP server in Claude Code:</p><pre>claude mcp add --transport http mcp-server-go http://localhost:8080/mcp</pre><p>Open Claude Code and run /mcp to verify that mcp-server-go is listed and connected. You can now ask Claude to invoke the echo or server_info tools directly from the conversation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7l0oxHeB0PpNSEGtJIIn_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIHvlj507e7Z6Cc537zvgA.png" /></figure><h3><strong>Conclusion</strong></h3><p>In this publication, we built a minimal MCP server in Go with two tools, exposed it over HTTP using gin, and installed it as a local MCP server in Claude Code. For a deeper dive into what’s possible with the mcp-go library, refer to the official documentation at <a href="https://github.com/mark3labs/mcp-go.">https://github.com/mark3labs/mcp-go.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50ed8a4c9ed4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go-ing Beyond the Ordinary: Discovering the Unique Superpowers of the Go Language]]></title>
            <link>https://pascalallen.medium.com/go-ing-beyond-the-ordinary-discovering-the-unique-superpowers-of-the-go-language-372bfbf54445?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/372bfbf54445</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Thu, 02 Jan 2025 16:09:01 GMT</pubDate>
            <atom:updated>2025-01-02T16:09:01.408Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7e0-5E9nHeBqwbd27FnE0Q.png" /></figure><p>From Fortune 500 heavyweights to indie open-source projects, many developers worldwide have already fallen in love with Go (also known as Golang). But why is this relatively young language sparking so much enthusiasm? Is it the lightning-fast compilation, the powerful concurrency model, or its crystal-clear simplicity? Let’s dive into Go’s unique features and see why it might just become your new programming best friend.</p><h3>1. A “Less is More” Philosophy</h3><p>One of Go’s defining characteristics is its simplicity. Designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson, Go was built with readability and clarity at its core.</p><ul><li><strong>Minimalistic syntax:</strong> The language intentionally avoids complex features like inheritance and generics (though there is now a lightweight form of generics in the more recent versions), preventing the code from ballooning into an unmanageable monstrosity.</li><li><strong>Fewer keywords:</strong> With fewer keywords than many other languages, Go’s syntax is easy to memorize, making it beginner-friendly yet powerful enough to handle large-scale applications.</li></ul><p>This “less is more” approach means developers can spend more time writing clean, understandable code rather than fighting the language itself.</p><h3>2. Concurrency: Goroutines and Channels</h3><p>Arguably the most talked-about feature of Go is its built-in support for concurrency. Concurrency is the ability to execute multiple tasks at once (or at least in an overlapping manner). Go’s secret sauce here comes in two parts:</p><ol><li><strong>Goroutines:</strong> Lightweight threads managed by the Go runtime. A typical thread in other languages can be quite heavy in terms of resources, but Goroutines share their memory footprint, making it possible to launch thousands (or even millions!) of them without dragging your system to a crawl.</li><li><strong>Channels:</strong> A means of communication between Goroutines, inspired by the Communicating Sequential Processes (CSP) model. Channels allow you to synchronize your Goroutines safely without complicated locking mechanisms. Instead of exposing shared memory, you pass messages (data) around through channels, which is often more intuitive.</li></ol><p>In short, Go’s concurrency makes it a breeze to write programs that scale well across multiple cores, whether you’re running a tiny script or powering an internet-scale application.</p><h3>3. Speed and Efficiency</h3><p>Yes, it’s simple and yes, it’s user-friendly. But don’t be fooled: Go is also fast. With a powerful compiler and runtime that efficiently manages memory through garbage collection, Go stands toe-to-toe with languages like C++ and Rust when it comes to performance in many scenarios.</p><ul><li><strong>Compiled to machine code:</strong> Go compiles down to a single, statically linked binary on every platform, so there’s no extra overhead or dependency hell at runtime.</li><li><strong>Garbage collection (GC):</strong> A well-optimized GC keeps memory usage in check without burdening the developer with manual memory management. In modern versions of Go, GC pauses have become impressively small, ensuring low-latency performance.</li></ul><p>For companies operating at scale, these performance benefits translate to improved response times, reduced costs, and a development workflow that doesn’t sacrifice productivity for speed.</p><h3>4. Cross-Compilation Made Easy</h3><p>Let’s say you develop an application on your Mac but need to deploy it on a Linux server running on ARM processors. In some languages, you’d be wrestling with configuration files, installing cross-compilers, or relying on containerization.</p><p>With Go, it’s straightforward:</p><pre>GOOS=linux GOARCH=arm go build</pre><p>One command, and you get a Linux binary for ARM. This frictionless cross-compilation is pure gold for developers building cloud-native microservices, IoT devices, or distributed systems spanning various platforms.</p><h3>5. Vibrant Standard Library</h3><p>Go’s standard library is jam-packed with useful packages that help you handle everything from HTTP servers to cryptography, templating, and file I/O. It saves you from hunting for third-party libraries for many common tasks.</p><p>Some highlights include:</p><ul><li><strong>net/http</strong> for quickly spinning up web services.</li><li><strong>database/sql</strong> for interacting with different databases in a consistent way.</li><li><strong>fmt</strong> for formatting and printing text without fuss.</li></ul><p>Having such a thorough “toolkit” at your fingertips accelerates development, so you can focus on writing features rather than wrestling with dependencies.</p><h3>6. Built-In Testing and Profiling</h3><p>Go’s creators recognized early on that testing is integral to software quality, so they baked testing tools right into the language. Go’s testing package, combined with the go test command, makes it incredibly convenient to write and run unit tests, ensuring you maintain code quality as your project grows.</p><p>Moreover, Go has built-in profiling tools (pprof) to measure CPU usage, memory allocation, and more. This visibility lets you pinpoint bottlenecks and fine-tune performance without needing to glue together multiple third-party utilities.</p><h3>7. The Go Community (and Gophers!)</h3><p>Go’s community is known for being welcoming and diverse. Whether you’re brand-new to coding or a veteran polyglot programmer, you’ll likely find:</p><ul><li><strong>Accessible documentation:</strong> Clear examples and easy-to-navigate references on the official <a href="https://go.dev/">Go website</a>.</li><li><strong>Open-source ecosystem:</strong> Thousands of projects, libraries, and frameworks on GitHub to tackle just about any problem you can think of.</li><li><strong>Conferences and meetups:</strong> Regular local and global events where “Gophers” (the affectionate term for Go enthusiasts) share experiences, best practices, and new ideas.</li></ul><p>This supportive network is a huge advantage when learning a new technology — it’s hard to get stuck for long with so many resources available.</p><h3>8. Tooling That Just Works</h3><p>The Go toolchain is refreshingly straightforward. Key commands like go build, go run, and go test are consistent across projects. And with Go modules (introduced in Go 1.11 and becoming standard in Go 1.13+), dependency management is both simpler and more reliable than older approaches like GOPATH.</p><p>Additionally, gofmt (the auto-formatting tool) singlehandedly eliminates “tabs vs. spaces” debates. With a quick command, your code is automatically formatted according to standard conventions. This consistency fosters readable, maintainable code that looks the same across teams and codebases.</p><h3>9. Generics… in a Go-Like Way</h3><p>For years, Go famously did not include generics, in part to avoid complexity and keep code readable. But starting with Go 1.18, the language introduced a simplified form of generics. Although narrower in scope compared to some other languages, these “Go-like” generics enable you to write reusable functions and data structures without losing Go’s characteristic simplicity.</p><p>It’s a helpful addition for anyone who wants to reduce boilerplate code — something that’s especially beneficial in certain algorithmic or data-processing contexts.</p><h3>10. Real-World Success Stories</h3><p>Lastly, Go isn’t just a theoretical darling — it has the production track record to back it up. Organizations like Google, Uber, Kubernetes, Docker, and Dropbox rely heavily on Go for high-traffic services and platforms. Whether you need to build a CLI tool or a distributed back-end system, you’ll be in good company.</p><h3>Conclusion: Ready, Set, Go!</h3><p>Go has carved a niche in the software development world by delivering on three major promises: simplicity, speed, and reliability. Its concurrency model — powered by Goroutines and Channels — makes scaling easier. Meanwhile, its built-in testing, vibrant standard library, and strong community support help you ship quality software faster.</p><p>Whether you’re a beginner searching for a first language to learn, or a seasoned developer looking for a new tool to solve complex, high-performance problems, Go is well worth your time. With Go in your toolbox, you might just find yourself saying: “Let’s Go!” more often than you think.</p><p><strong>Did you enjoy this article?</strong></p><p>Feel free to share your thoughts, questions, or Go success stories in the responses below. And if you’re ready to dive into the Go universe, head over to the <a href="https://go.dev/">official Go website</a> for documentation, tutorials, and more resources to kickstart your journey!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=372bfbf54445" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering the Fundamentals of Algorithms: A Beginner’s Guide]]></title>
            <link>https://pascalallen.medium.com/mastering-the-fundamentals-of-algorithms-a-beginners-guide-364adaf31556?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/364adaf31556</guid>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 17:49:57 GMT</pubDate>
            <atom:updated>2024-11-21T17:56:20.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BH4seEQQfZ6NY9UK" /><figcaption>Photo by <a href="https://unsplash.com/@thetechnomaid?utm_source=medium&amp;utm_medium=referral">Sophie Elvis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Algorithms power the technology we use daily, from searching through data to sorting our emails. Understanding their efficiency and use cases is a foundational skill for any aspiring computer scientist or programmer. Let’s explore some core algorithms, their efficiency, and how they work step by step.</p><h3><strong>Search Algorithms</strong></h3><p><strong>Linear Search</strong></p><p><strong>How it works:</strong> Iterates through an array sequentially from left to right until the desired element is found.</p><p><strong>Efficiency:</strong></p><ul><li><strong>Best case:</strong> Ω(1) (element is found immediately)</li><li><strong>Worst case:</strong> O(n) (element is at the end or not in the array)</li></ul><p><strong>Use case:</strong> Simple and effective for small, unsorted datasets.</p><p><strong>Binary Search</strong></p><p><strong>How it works:</strong> Requires a <strong>sorted list</strong>. Recursively divides the search space in half, checking the middle element and deciding to go left or right.</p><p><strong>Efficiency:</strong></p><ul><li><strong>Best case:</strong> Ω(1) (element is in the middle)</li><li><strong>Worst case:</strong> O(log n) (repeated halving of the search space)</li></ul><p><strong>Use case:</strong> Ideal for large, sorted datasets.</p><h3><strong>Sorting Algorithms</strong></h3><p><strong>Bubble Sort</strong></p><p><strong>How it works:</strong> Compares adjacent elements and swaps them if they’re out of order. This “bubbling” process continues until the list is sorted.</p><p><strong>Pseudocode Highlights:</strong></p><ol><li>Initialize a swap counter.</li><li>Iterate through the list, swapping elements as needed.</li><li>Stop when no more swaps are required.</li></ol><p><strong>Efficiency:</strong></p><ul><li><strong>Best case:</strong> Ω(n) (already sorted list)</li><li><strong>Worst case:</strong> O(n²) (completely unsorted list)</li></ul><p><strong>Use case:</strong> Educational purposes; rarely used in practice due to inefficiency.</p><p><strong>Selection Sort</strong></p><p><strong>How it works:</strong> Finds the smallest element in the unsorted part of the list and swaps it with the first unsorted element.</p><p><strong>Efficiency:</strong></p><ul><li><strong>Best and worst case:</strong> O(n²)</li></ul><p><strong>Use case:</strong> Simple to implement but inefficient for large datasets.</p><p><strong>Merge Sort</strong></p><p><strong>How it works:</strong> A divide-and-conquer algorithm that:</p><ol><li>Splits the list into halves.</li><li>Recursively sorts each half.</li><li>Merges the sorted halves back together.</li></ol><p><strong>Efficiency:</strong></p><ul><li><strong>Best and worst case:</strong> O(n log n)</li></ul><p><strong>Use case:</strong> Highly efficient for large datasets.</p><h3><strong>Recursive Functions</strong></h3><p>A function that calls itself with a smaller input.</p><p><strong>Components:</strong></p><ol><li><strong>Base case:</strong> Stops recursion.</li><li><strong>Recursive case:</strong> Performs the repeated operation.</li></ol><p><strong>Example:</strong> Factorial function</p><ul><li>fact(3) = 3 * fact(2)</li><li>fact(2) = 2 * fact(1)</li><li>fact(1) = 1 (base case)</li></ul><h3><strong>Big O Notation: Understanding Efficiency</strong></h3><ul><li><strong>Upper Bound (O):</strong> Maximum number of steps an algorithm will take.</li><li><strong>Lower Bound (Ω):</strong> Minimum number of steps an algorithm will take.</li></ul><p>Knowing these bounds helps predict an algorithm’s behavior in best- and worst-case scenarios.</p><h3><strong>Conclusion</strong></h3><p>Algorithms are the backbone of computational problem-solving. By understanding their workings and efficiencies, you’ll be better equipped to choose the right one for your task and optimize your code effectively. Start experimenting with these foundational algorithms and explore their real-world applications!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=364adaf31556" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate Your Deployments With Cron]]></title>
            <link>https://pascalallen.medium.com/automate-your-deployments-with-cron-7174ecb9f52f?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/7174ecb9f52f</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[cron]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 14:49:50 GMT</pubDate>
            <atom:updated>2023-11-02T09:29:34.677Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R9s5jJjC8X1cZaz6" /><figcaption>Photo by <a href="https://unsplash.com/@christianlue?utm_source=medium&amp;utm_medium=referral">Christian Lue</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Firstly, for succinctness, I will presume that you have an existing project on an existing Linux server. Secondly, this is purely demonstrative and is not a be-all-end-all solution for deployments. It’s important to have a clear understanding of what your needs are when deploying. This is a very basic solution. Use the information that you learn here today and consider plenty of other options to make an informed decision about your deployment process.</p><h3>Creating a Deployment Script</h3><p>Let’s start by adding a scripts/ directory to our project and within that directory add the following boilerplate code to a file named cron-deploy:</p><pre>#!/usr/bin/env bash<br><br># change to the project root<br>DIR=&quot;$(cd &quot;$(dirname &quot;${BASH_SOURCE[0]}&quot;)&quot; &amp;&amp; pwd)&quot;<br>cd &quot;$DIR&quot;/.. || exit<br><br># create bash environment variables from .env file<br>export &quot;$(grep -v &#39;^#&#39; .env | xargs -d &#39;\n&#39;)&quot;<br><br># change to main branch, if needed<br>BRANCH=&quot;$(git branch --show-current)&quot;<br>if [ &quot;$BRANCH&quot; != &quot;main&quot; ]<br>then<br>  git checkout main -q<br>fi<br><br># bring up environment, if changes have been made<br>GIT_STATUS=&quot;$(git status -s)&quot;<br>if [ -n &quot;$GIT_STATUS&quot; ]<br>then<br>  git pull \<br>    &amp;&amp; docker compose --progress quiet down \<br>    &amp;&amp; docker system prune -a -f \<br>    &amp;&amp; docker builder prune -a -f \<br>    &amp;&amp; docker compose -f docker-compose.yml --progress quiet build \<br>    &amp;&amp; docker compose -f docker-compose.yml --progress quiet up -d \<br>    &amp;&amp; yarn install --frozen-lockfile \<br>    &amp;&amp; webpack --config webpack.config.js --mode production<br>fi<br><br># send notification, if services are not running<br>DOCKER_STATUS=&quot;$(docker compose ps --status running --format &quot;{{.Name}}&quot;)&quot;<br>if [[ &quot;$DOCKER_STATUS&quot; != *&quot;pascalallen-go&quot;* ]] || [[ &quot;$DOCKER_STATUS&quot; != *&quot;pascalallen-postgres&quot;* ]]<br>then<br>  curl -H &quot;Content-type: application/json&quot; \<br>    --data &#39;{&quot;channel&quot;:&quot;$SLACK_CHANNEL_ID&quot;,&quot;blocks&quot;:[{&quot;type&quot;:&quot;section&quot;,&quot;text&quot;:{&quot;type&quot;:&quot;mrkdwn&quot;,&quot;text&quot;:&quot;Deploy *_failed_*.&quot;}}]}&#39; \<br>    -X POST &quot;$SLACK_DM_URL&quot;<br>fi</pre><p>There’s a bit to unpack here. Let’s break it down in order.</p><ol><li>The first thing our script does is change to the project root.</li><li>From the root of the project, we now export our environment variables from our project’s .env file so that we can access those variables in our bash script.</li><li>We then change to the main git branch, if we’re not already on it.</li><li>Next, we check the git status and, if there are changes, rebuild our application. These commands are specific to your application and should be changed. In this example, I’m rebuilding the project’s Docker services and recompiling the project’s JavaScript with yarn/webpack.</li><li>The last thing our script does is send a notification to Slack if any of our Docker services are not running.</li></ol><p>This script makes several assumptions and is close to a very basic real-world scenario to automatically deploy your Docker services. The bulk of the script depends on your build process and should be changed to fit your needs. Again, this is boilerplate code for demonstration — you will need to replace the code with specific comprehensive steps in order to deploy your app.</p><h3>Automating Your Script With Cron</h3><p>Now that we’ve created and added a script to our project containing comprehensive deployment steps, the next thing that we need to do is automate the script to run recursively. We can do that with cron. So, let’s open our cron table file by running:</p><pre>crontab -e</pre><p>And at the bottom of this file, add the following line:</p><pre>* * * * * /your/path/to/project/scripts/cron-deploy</pre><p>Save and close this file. This cron job runs your deploy script once a minute, checking if changes have been made to the main git branch of your application and then running the deploy steps accordingly.</p><p>That’s it, you’re done!</p><p>To check the status of your cron job, run the following command:</p><pre>sudo service cron status</pre><p>For debugging, you can redirect your script output to a temporary log file for viewing. Just edit the cron job by running crontab -e and adding:</p><pre>* * * * * /your/path/to/project/scripts/cron-deploy &gt;&gt; /tmp/cron-deploy.log</pre><h3>Conclusion</h3><p>Thank you for stopping by. I hope this publication, at the very least, teaches you a <em>minimal</em> approach to autonomous deploys with cron and bash scripting. My intent with this publication was to be short and sweet, and to arm you with the basics so that you’re able to determine a deploy process that works for your project. Have a great day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7174ecb9f52f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To: Build a gRPC Server In Go]]></title>
            <link>https://pascalallen.medium.com/how-to-build-a-grpc-server-in-go-943f337c4e05?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/943f337c4e05</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[protocol-buffers]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[rpc]]></category>
            <category><![CDATA[remote-procedure-calls]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 20:30:15 GMT</pubDate>
            <atom:updated>2023-10-04T17:25:10.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xZXmBNa-o0P5YYsKmsKO0Q.png" /></figure><p>In this publication I will demonstrate how a Go client can directly call a method on a Go server using gRPC.</p><h3>Prerequisites</h3><ul><li><a href="https://go.dev/dl/">Go</a></li></ul><p>gRPC is a framework for Remote Procedure Calls, or RPCs, with a wide variety of supported <a href="https://grpc.io/docs/languages/">languages</a>. In gRPC there are 3 core concepts: <strong>protocol buffers</strong>, <strong>servers</strong>, and <strong>stubs</strong>. Let’s look at each concept in practice below.</p><h3>Protocol Buffer Compiler Installation</h3><p>The first thing we need to do is install the protocol buffer compiler. Visit <a href="https://github.com/protocolbuffers/protobuf/releases">https://github.com/protocolbuffers/protobuf/releases</a> in your browser and download the zip file that corresponds to your OS and computer architecture.</p><p>Next, unzip the file under $HOME/.local by running the following command, where protoc-24.3-osx-universal_binary.zip is the zip file that corresponds to your OS and computer architecture:</p><pre>unzip protoc-24.3-osx-universal_binary.zip -d $HOME/.local</pre><p>Now update your environment’s PATH variable to include the path to the protoc executable by adding the following code to your .bash_profile or .zshrc file:</p><pre>export PATH=&quot;$PATH:$HOME/.local/bin&quot;</pre><p>Note: If your .bash_profile or .zshrc file already contains an export path, you can simply append :$HOME/.local/bin.</p><h3>Protocol Buffer Go Plugin Installation</h3><p>Now that we have the protocol buffer compiler installed, protoc, we need to install a couple of plugins so that our protocol buffer code works with the Go runtime.</p><p>So, from a new terminal window run the following command:</p><pre>go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \<br>  &amp;&amp; go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest</pre><p>And once more, update your environment’s PATH variable to include the path to the compiled Go executables by adding :<strong>$(</strong>go env GOPATH<strong>)</strong>/bin to your .bash_profile or .zshrc file. Your PATH variable should now look something like this:</p><pre>export PATH=&quot;$PATH:$HOME/.local/bin:$(go env GOPATH)/bin&quot;</pre><p>Great! We’re now ready to build our project.</p><h3>Project Initialization</h3><p>Let’s start by creating a new directory for our project, initialize our Go module, and install Go dependencies:</p><pre>mkdir grpc-go \<br>  &amp;&amp; cd grpc-go \<br>  &amp;&amp; go mod init github.com/pascalallen/grpc-go \<br>  &amp;&amp; go mod tidy</pre><p>Now from the root of the project, let’s create 3 subdirectories:</p><pre>mkdir client helloworld server</pre><p>These 3 subdirectories will contain our Go client application, Go server application, and our Hello World gRPC service.</p><p>cd into the helloworld directory and create a file called helloworld.proto at the root of the project and add the following code:</p><pre>syntax = &quot;proto3&quot;;<br><br>option go_package = &quot;github.com/pascalallen/grpc-go/helloworld&quot;;<br><br>package helloworld;<br><br>service HelloWorldService {<br>  rpc SayHello(HelloWorldRequest) returns (HelloWorldResponse) {}<br>}<br><br>message HelloWorldRequest {}<br><br>message HelloWorldResponse {<br>  string message = 1;<br>}</pre><p>This code defines our gRPC service and the method request and response types using protocol buffers. We’ll use this file to generate our gRPC server and stub interfaces.</p><p>From the helloworld directory, run the following command:</p><pre>protoc --go_out=. --go_opt=paths=source_relative \<br>    --go-grpc_out=. --go-grpc_opt=paths=source_relative \<br>    helloworld.proto</pre><p>This command generates 2 files for us in the helloworld directory:</p><ul><li>helloworld.pb.go, which contains all the protocol buffer code to populate, serialize, and retrieve request and response message types</li><li>helloworld_grpc.pb.go, which contains an interface type (or <em>stub</em>) for clients to call with the methods defined in the HelloWorldService service, and an interface type for servers to implement, also with the methods defined in the HelloWorldService service</li></ul><p>Let’s keep going!</p><h3>Server Implementation</h3><p>Now that we’ve installed the protocol buffer compiler, protocol buffer plugins for Go, and initialized our project, we’re ready to create our Go server application and Go client application. Let’s start with the server by cding into the server directory and creating a file called main.go with the following code:</p><pre>package main<br><br>import (<br> &quot;context&quot;<br> pb &quot;github.com/pascalallen/grpc-go/helloworld&quot;<br> &quot;google.golang.org/grpc&quot;<br> &quot;log&quot;<br> &quot;net&quot;<br>)<br><br>type server struct {<br> pb.UnimplementedHelloWorldServiceServer<br>}<br><br>func (s *server) SayHello(ctx context.Context, in *pb.HelloWorldRequest) (*pb.HelloWorldResponse, error) {<br> return &amp;pb.HelloWorldResponse{Message: &quot;Hello, World! &quot;}, nil<br>}<br><br>func main() {<br> lis, err := net.Listen(&quot;tcp&quot;, &quot;:50051&quot;)<br> if err != nil {<br>  log.Fatalf(&quot;failed to listen on port 50051: %v&quot;, err)<br> }<br><br> s := grpc.NewServer()<br> pb.RegisterHelloWorldServiceServer(s, &amp;server{})<br> log.Printf(&quot;gRPC server listening at %v&quot;, lis.Addr())<br> if err := s.Serve(lis); err != nil {<br>  log.Fatalf(&quot;failed to serve: %v&quot;, err)<br> }<br>}</pre><p>This code implements the service interface generated from our service definition in helloworld.proto and provisions a gRPC server and listens to requests on port 50051 from clients. But not quite yet since we still need to implement our Go client application. So let’s keep going.</p><h3>Client Implementation</h3><p>Similar to what we did in the step above, let’s create our Go client application by cding into the client directory and creating a file called main.go with the following code:</p><pre>package main<br><br>import (<br> &quot;context&quot;<br> pb &quot;github.com/pascalallen/grpc-go/helloworld&quot;<br> &quot;google.golang.org/grpc&quot;<br> &quot;google.golang.org/grpc/credentials/insecure&quot;<br> &quot;log&quot;<br> &quot;time&quot;<br>)<br><br>func main() {<br> conn, err := grpc.Dial(&quot;localhost:50051&quot;, grpc.WithTransportCredentials(insecure.NewCredentials()))<br> if err != nil {<br>  log.Fatalf(&quot;failed to connect to gRPC server at localhost:50051: %v&quot;, err)<br> }<br> defer conn.Close()<br> c := pb.NewHelloWorldServiceClient(conn)<br><br> ctx, cancel := context.WithTimeout(context.Background(), time.Second)<br> defer cancel()<br><br> r, err := c.SayHello(ctx, &amp;pb.HelloWorldRequest{})<br> if err != nil {<br>  log.Fatalf(&quot;error calling function SayHello: %v&quot;, err)<br> }<br><br> log.Printf(&quot;Response from gRPC server&#39;s SayHello function: %s&quot;, r.GetMessage())<br>}</pre><p>This code creates a gRPC channel to communicate with the gRPC server, creates a gRPC stub (client) to perform RPCs, and finally calls our SayHello function on the gRPC server.</p><h3>In Action</h3><p>Now that we’ve created our Go server and Go client, let’s see it in action by first spinning up the Go server. From the root of the project, run the following command <strong>to start the gRPC server</strong>:</p><pre>go run server/main.go</pre><p>And finally in a separate terminal window, run the following command <strong>to execute the gRPC client request</strong>:</p><pre>go run client/main.go</pre><p>The output in your client terminal window should look something like the following:</p><pre>2023/09/27 15:00:51 Response from gRPC server&#39;s SayHello function: Hello, World!</pre><p>And there you have it! Your first gRPC server and client implementation.</p><h3>Conclusion</h3><p>My goal for this publication was to contribute meaningful documentation to the gRPC and Go community. This was a very high-level tutorial and doesn’t detail everything. For more information on gRPC and Go, I recommend visiting <a href="https://grpc.io/docs/languages/go/">https://grpc.io/docs/languages/go/</a>. Have a great day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=943f337c4e05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing a Framework for Any Project]]></title>
            <link>https://pascalallen.medium.com/developing-a-framework-for-any-project-9cf7dac82ffe?source=rss-90601cdad783------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cf7dac82ffe</guid>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Pascal Allen]]></dc:creator>
            <pubDate>Wed, 13 Sep 2023 18:15:24 GMT</pubDate>
            <atom:updated>2023-09-13T18:15:24.960Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wcdpyrptCo_utj2m" /><figcaption>Photo by <a href="https://unsplash.com/@szolkin?utm_source=medium&amp;utm_medium=referral">Sergey Zolkin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First of all, if you are a software developer and reading this, the word “Framework” in the context of this publication is the overarching principle of business strategies in which we will detail below — not a code library in which you install. That being said, this publication should serve as a resource for designing and developing a product that can be easily maintained and extended by future software developers and domain experts.</p><p>Whether you are starting a new project or have a live product, my goal is to help you preserve and optimize functionality and utility. Let’s get started!</p><h3>Ubiquitous Language</h3><p>One of the first things to consider, is Ubiquitous Language. Ubiquitous Language is a language based on the software’s domain model that is comprehensible and expressive so that communication between domain experts and developers is unambiguous. Ubiquitous Language is specific to a bounded context, which means the terminology that you use for bounded context “A” may mean something different in bounded context “B”. Ubiquitous Language originates from Domain-Driven Design which we won’t be diving into during this publication but if you’re curious to learn about DDD, I recommend starting <a href="https://martinfowler.com/bliki/DomainDrivenDesign.html">here</a>.</p><h3>Agile Software Development</h3><p>To put it simply, Agile Software Development is a methodology in which self-organizing teams collaborate to discover requirements and improve solutions. Agile Software Development originates from the Manifesto for Agile Software Development which was created by a team of brilliant software developers back in 2001. More information on the manifesto can be found <a href="http://agilemanifesto.org/">here</a>. The manifesto basically says that there are four main principles in Agile Software Development:</p><ol><li>Individuals and interactions &gt; processes and tools</li><li>Working software &gt; comprehensive documentation</li><li>Customer collaboration &gt; contract negotiation</li><li>Responding to change &gt; following a plan</li></ol><p>Agile Software Development is also based off of several different software development frameworks, one of which is Scrum. We won’t dive into Scrum during this publication, but I highly recommend it for your next project. To learn more about Scrum, you can start <a href="https://en.wikipedia.org/wiki/Scrum_(software_development)">here.</a></p><h3>Event Storming</h3><p>Event Storming is a workshop-based meeting in which software developers and domain experts use sticky notes and a wall for business process modeling. Just like any other meeting, it’s important to have the relevant people present only. The software developers will know what questions to ask, regarding the business process that you are storming out, and the domain experts should be able to provide answers to those questions. After enough data is gathered, you and the others are ready to begin filling out sticky notes in the following categories:</p><ol><li><strong>Domain event</strong> (orange)<br>An event that occurs in the business process. Written in past tense.</li><li><strong>Actor</strong> (yellow)<br>A person who executes a command through a view.</li><li><strong>Business process </strong>(purple)<br>Processes a command according to business rules and logic. Creates one or more domain events.</li><li><strong>Command</strong> (blue)<br>A command executed by a user through a view on an aggregate that results in the creation of a domain event.</li><li><strong>Aggregate</strong> (yellow)<br>Cluster of domain objects that can be treated as a single unit.</li><li><strong>External system </strong>(pink)<br>A third-party service provider such as a payment gateway or shipping company.</li><li><strong>View</strong> (green)<br>A view that users interact with to carry out a task in the system.</li></ol><p>Sticky notes are then put up on a whiteboard or wall so that the business process can be seen by all.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7wvPZWtO65UYxhxQJlE-Q.jpeg" /></figure><p>Event storming can be repeated for each new business process or feature that your organization needs fleshed out. To learn more about event storming, you can visit <a href="https://www.eventstorming.com/">https://www.eventstorming.com/</a> and <a href="https://en.wikipedia.org/wiki/Event_storming">https://en.wikipedia.org/wiki/Event_storming</a>.</p><h3>Project Tracking System</h3><p>A project tracking system allows you to plan for, track, and organize milestones as your project undergoes development. There are dozens of services available on the web. A few popular at the moment are <a href="https://www.atlassian.com/software/jira">Jira</a>, <a href="https://monday.com/">Monday</a>, and <a href="https://trello.com/">Trello</a>. Choosing viable project tracking software depends on project complexity, team size, and several other factors. It’s ultimately a team decision to determine which is right for you.</p><p>After subscribing to a project tracking system, swim lanes and columns make it easy to track the progress of tickets. For a small project and team, you might use Trello and simply have columns: To Do, Doing, Done. For medium to large projects and teams, you might have a more involved workflow in which case Jira might be a good candidate with columns like: Blocked, To Do, Doing, Review, QA, Done.</p><h3>Version Control System</h3><p>Version control is the process of tracking and managing changes to your software’s code. A version control system gives you an interface and the tools needed for version control, allowing your team to easily manage changes to your software’s code over time. The term for where your source code will live is a “repository.” A repository is typically created per project whereby a branching strategy is decided on by your team and put in place so that developers are able to continuously integrate code simultaneously by way of pull requests.</p><p>Here is a version control specification that has worked well for my team and I in the past:</p><p><strong>Base Branches</strong></p><p>develop: default branch</p><p>main: production branch</p><p><strong>Branch Naming Convention</strong></p><p>ABC-123-ListUsersAPI: typical feature branch branched off of the latest version of the develop branch where ABC-123 references the Project Tracking System’s ticket number followed by a hyphen and Pascal-cased set of words briefly describing the feature</p><p><strong>Pull Request Title</strong></p><p>A typical feature pull request should have a title describing the feature prefixed with the Project Tracking System’s ticket number. Examples, “ABC-123 List Users API” and “ABC-123 List Users View”.</p><p><strong>Pull Request Description</strong></p><p>A typical feature pull request should have a description describing what it is that the PR is doing, followed by testing instructions. Example, “This PR adds an API endpoint to retrieve all users. To test, bring up the project and use curl to execute a GET request to the newly added API endpoint at http://localhost:8080/api/v1/users. The response should contain a list of users.”</p><p><strong>Pull Request Reviewers</strong></p><p>Anyone who should review the PR.</p><p><strong>Pull Request Assignee</strong></p><p>Yourself or the developer that worked on the PR.</p><p><strong>Merging</strong></p><p>A typical feature pull request should have a passing build (GitHub Actions), addressed feedback, and a minimum of 2 approvals before the PR’s assignee merges the PR.</p><p><strong>Best Practices</strong></p><ul><li>It’s a good idea to get into the habit of running git pull prior to creating branches so that your created branch has the latest version of its parent branch. git pull should also be ran before writing code on a shared branch for the same reason.</li><li>It’s a good idea to get into the habit of testing your code prior to committing any code. Check for failing unit test and linter errors as well.</li><li>Stay up to date with PR notifications, it’s a good idea to address PR feedback as it comes into your email inbox so that feedback doesn’t pile up.</li><li>If there are more than 6 stale PRs open, feel free to drop a quick message in the team’s communication platform reminding the team to get some eyes on open PRs when they have a chance. I typically do this in the mornings, if necessary.</li></ul><p>There is a lot to unpack here, and I’m being fairly presumptuous that you have decided to go with Git as your version control system. I do recommend Git as your version control system as it is free and open source. To learn more about Git, you can visit their website <a href="https://git-scm.com/">here</a>. Remember, this is but one man’s humble approach to a version control specification. Do your own research and come up with a specification that works for you and your team.</p><h3>Communication Platform</h3><p>A communication platform is a service that allows your organization to communicate in real-time. Two of the most popular communication platforms at the moment are <a href="https://teams.microsoft.com/">Microsoft Teams</a> (previously Skype) and <a href="https://slack.com/">Slack</a>. As always, the decision on which platform to use depends on your organization’s needs. I’m a huge fan of Slack as it does everything that my org needs and then some. Some things to consider when choosing a communication platform:</p><ul><li>User-friendly interface</li><li>Security</li><li>Video messaging</li><li>Screen sharing</li><li>3rd-party app integrations</li><li>Scalability</li><li>Software reliability and support</li></ul><h3>Conclusion</h3><p>I hope this publication was (at the very least) an enjoyable read. If you learned something, I’d love to hear from you in the comments section!</p><p>Until next time,</p><p>Pascal</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cf7dac82ffe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>