Giter Site home page Giter Site logo

packtpublishing / event-driven-architecture-in-golang Goto Github PK

View Code? Open in Web Editor NEW
278.0 4.0 99.0 3.01 MB

Event-Driven Architecture in Golang, published by Packt

License: MIT License

Makefile 0.16% Go 53.60% HTML 12.07% JavaScript 0.30% Shell 2.28% Dockerfile 0.15% CSS 29.53% Gherkin 0.11% HCL 1.79% PowerShell 0.02%

event-driven-architecture-in-golang's Introduction

Event-Driven Architecture in Golang

This is the code repository for Event-Driven Architecture in Golang, published by Packt.

Building complex systems with asynchronicity and eventual consistency

What is this book about?

Event-Driven Architecture in Golang is an approach used to develop applications that shares state changes asynchronously, internally, and externally using messages. EDA applications are better suited at handling situations that need to scale up quickly and the chances of individual component failures are less likely to bring your system crashing down.

This book covers the following exciting features:

  • Understand different event-driven patterns and best practices
  • Plan and design your software architecture with ease
  • Track changes and updates effectively using event sourcing
  • Test and deploy your sample software application with ease
  • Monitor and improve the performance of your software architecture

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

BEGIN;
-- execute queries, updates, inserts, deletes ...
PREPARE TRANSACTION 'bfa1c57a-d99d-4d74-87a9-3aaabcc754ee';

Following is what you need for this book: This hands-on book is for intermediate-level software architects, or senior software engineers working with Golang and interested in building asynchronous microservices using event sourcing, CQRS, and DDD. Intermediate-level knowledge of the Go syntax and concurrency features is necessary.

With the following software and hardware list you can run all code files present in the book (Chapter 1-12).

Software and Hardware List

Chapter Software required OS required
1-12 Go 1.18+ Windows, Mac OS X, and Linux (Any)
1-12 Docker 20.10.x Windows, Mac OS X, and Linux (Any)
1-12 NATS 2.4 Windows, Mac OS X, and Linux (Any)

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know the Author

Michael Stack is a solutions architect with more than 20 years experience developing software. He has been working with Golang for over seven years. During his career he has developed numerous N-tier applications, and is focused on development involving microservices and other distributed applications running in the cloud.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781803238012

event-driven-architecture-in-golang's People

Contributors

blockchaindev999 avatar packt-itservice avatar packt-pradeeps avatar stackus avatar urvis123 avatar v8tix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

event-driven-architecture-in-golang's Issues

Chapter 3: running make install-tools throws error

I run into problems when executing make

❯ make install-tools
installing tools
/bin/sh: @go: command not found
make: *** [install-tools] Error 127

When I removed " && \" from Makefile it worked for me.

Looks like this

install-tools:
	@echo installing tools # removed  && \
	@go install \
	github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
	github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
	google.golang.org/protobuf/cmd/protoc-gen-go \
	google.golang.org/grpc/cmd/protoc-gen-go-grpc
	@echo done

Laptop: iMac 3,6 GHz Quad-Core Intel Core i7
make: GNU Make 3.81
go: go version go1.22.2 darwin/amd64

Docker build fails

Running make build results in a docker failure COPY failed: forbidden path outside the build context: .. ()

Chapter 7 and onwards should also include link to search swagger spec

+++ b/Chapter07/internal/web/index.html
@@ -43,6 +43,7 @@
                                {name: "Payments", url: "payments-spec/api.swagger.json"},
                                {name: "Store Management", url: "stores-spec/api.swagger.json"},
                                {name: "Shopping Baskets", url: "baskets-spec/api.swagger.json"},
+                               {name: "Search", url: "search-spec/api.swagger.json"},
                        ],
                        dom_id: '#swagger-ui',
                        deepLinking: true,

Do domain events implement jetstream

Not an issue - more of a curiosity, in the di, does jetstream get injected as the transport for domain events? I understand that integration events are for service to service communication, but was not sure if domain level events also leveraged jetstream as the transport

Chapter 4 database would not connect

I am going through the book, just on chapter 4. When I tried to initialize a shopping basket through the Swagger UI, I got the following error:

{
  "code": 13,
  "message": "failed to connect to `host=/tmp user=mallbots_user database=mallbots`: dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory)",
  "details": [
    {
      "@type": "type.googleapis.com/errors.ErrorType",
      "TypeCode": "INTERNAL_SERVER_ERROR",
      "HTTPCode": "500",
      "GRPCCode": "13"
    }
  ]
}

I was able to fix it by directly setting environment variables in the docker-compose file rather than loading via env_file:

services:
  monolith:
    ...
    environment:
    - PG_CONN=host=postgres dbname=mallbots user=mallbots_user password=mallbots_pass
    - ENVIRONMENT=development
    # env_file:
    #   - docker/.env

For some reason the .env file wasn't being read.

On MacOS Monterey 12.5

Thank you for the book BTW. Learning a ton and protobufs are blowing my mind 🤯

Chapter 4 code fails on Ubuntu 22

Some kind of permissions problems from Python code. Could this be a problem with setup? The book doesn't say anything about Python related setup.

$ docker-compose up -d
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
sock.connect(self.unix_socket)
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 718, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
return self.version(api_version=False)["ApiVersion"]
File "/usr/lib/python3/dist-packages/docker/api/daemon.py", line 181, in version
return self._result(self._get(url), json=True)
File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 237, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/docker-compose", line 33, in
sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
command_func()
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
project = project_from_options('.', options)
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
return get_project(
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
client = get_client(
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
client = docker_client(
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 197, in init
self._version = self._retrieve_server_version()
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 221, in _retrieve_server_version
raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))

Chapter 4 - postgres init scripts fail to run

I noticed that postgres init scripts from ./docker/database in Chapter04 are not running due to bad permissions:

postgres  | /usr/local/bin/docker-entrypoint.sh: /docker-entrypoint-initdb.d/1_create_monolith_db.sh: /bin/bash: bad interpreter: Permission denied
postgres exited with code 126

Maybe we can update them with something like chmod 755 ./docker/database/*.sh ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.