SaleSphereAPI

module
v0.0.0-...-c64bf0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: Apache-2.0

README

Sales Backend Web API

Install

Upgrade/Increment to Latest Stable Version

  • run make deps-upgrade
  • Makefile
  • Dockerfile

Steps

Kind creates a cluster named "sale-sphere-cluster" using the specified image (kindest/node:v1.29.2) and configuration file (zarf/k8s/dev/kind-config.yaml).

Xnapper-2024-03-06-01 13 54

In setting up a Kubernetes cluster, I ensure that the required node image is available, prepare the nodes for the cluster, and configure the cluster accordingly. Once configured, I start the control plane and proceed to install essential components such as the Container Network Interface (CNI) and StorageClass. Upon successful creation of the cluster, I set the kubectl context to "kind-sale-sphere-cluster," enabling seamless interaction with the newly created cluster.

image

This log shows the execution of the make all command, which typically builds and prepares various components of a project. Here's a breakdown of the steps:

Using Docker, I construct an image based on the provided Dockerfile located at zarf/docker/Dockerfile.service. To mention, to ensure compatibility with Podman, the image is labeled as localhost/shohinsan/salesphereapi/sales-api:0.0.1. Throughout the build process, specific arguments are transmitted:

  • BUILD_REF is designated as 0.0.1
  • BUILD_DATE is established as the present date and time in UTC format (%Y-%m-%dT%H:%M:%SZ).

In the build progression, we initiate by establishing the foundational environment, loading essential base and build images such as alpine:3.19.1 and golang:1.22.1 respectively. Following this, we seamlessly integrate required files and configurations by transferring the build context, ensuring all necessary dependencies are resolved and extracted. Security measures are implemented by configuring user and directory permissions within the image. We then copy pertinent local files into the Docker image, facilitating runtime accessibility. Specifying the working directory within the image streamlines operations. Finally, the Go application undergoes compilation using the "go build" command, transforming it into an executable within the Docker environment.

image

Upon invoking "make dev-status-all" command, the current status of the development environment is queried using various Kubernetes commands. Specifically, "kubectl get pods -o wide --watch --all-namespaces" command retrieves the status of all pods across namespaces. However, to focus solely on the "sales-system" namespace, we need to filter the results. Ensuring that only pods within the "sales-system" namespace are considered, it is observed that the pod named "sales-5bc95c6f54-cs2l9" is indeed running, indicating the successful functioning of the "sales-system" components.

image

Resource limits for CPU and memory are set to ensure efficient operation. The bottom line of this thorough examination is not to run more threads than we have cores in order to run as efficiently as possible.

image

This is just a beginning, but I was able to install and run an interesting monitoring tool expvarmon that watches every 5 seconds. Funny enough, with that you will be able to run monitoring tests at the airplane without an internet if you are coding out there.

image

Upon executing the "make curl" command, a cURL request is made to http://localhost:3000/hack, resulting in an HTTP response with a status code of 200 OK. The response includes a content type of text/plain and a content length of 16 bytes. This successful response indicates that the specified endpoint is accessible and responsive within the application environment.

image

Learning Rego, the policy language used in Open Policy Agent (OPA), proved to be challenging yet rewarding. Despite its steep learning curve, understanding Rego's syntax and semantics allowed for fine-grained control over policy enforcement within the system. I implemented and verified JSON Web Tokens (JWT) using this technology.

image

Added Open-Telemetry using Promtail/Loki/Tempo for Grafana to see 3 different logs such as "logs", "metrics", and "traces". Some tests were added after user created via Postgres Database

Directories

Path Synopsis
app
services/metrics/collector
Package collector is a simple collector for
Package collector is a simple collector for
services/metrics/publisher
Package publisher manages the publishing of metrics.
Package publisher manages the publishing of metrics.
services/metrics/publisher/datadog
Package datadog provides support for publishing metrics to DD.
Package datadog provides support for publishing metrics to DD.
services/metrics/publisher/expvar
Package expvar manages the publishing of metrics to stdout.
Package expvar manages the publishing of metrics to stdout.
services/metrics/publisher/prometheus
Package prometheus provides suppoert for sending metrics to prometheus.
Package prometheus provides suppoert for sending metrics to prometheus.
services/sales-api/build/all
Package all binds all the routes into the specified app.
Package all binds all the routes into the specified app.
services/sales-api/build/crud
Package crud binds the crud domain set of routes into the specified app.
Package crud binds the crud domain set of routes into the specified app.
services/sales-api/build/reporting
Package reporting binds the reporting domain set of routes into the specified app.
Package reporting binds the reporting domain set of routes into the specified app.
services/sales-api/handlers/checkgrp
Package checkgrp maintains the group of handlers for health checking.
Package checkgrp maintains the group of handlers for health checking.
services/sales-api/handlers/homegrp
Package homegrp maintains the group of handlers for home access.
Package homegrp maintains the group of handlers for home access.
services/sales-api/handlers/productgrp
Package productgrp maintains the group of handlers for product access.
Package productgrp maintains the group of handlers for product access.
services/sales-api/handlers/trangrp
Package trangrp maintains the group of handlers for transaction example.
Package trangrp maintains the group of handlers for transaction example.
services/sales-api/handlers/usergrp
Package usergrp maintains the group of handlers for user access.
Package usergrp maintains the group of handlers for user access.
services/sales-api/handlers/vproductgrp
Package vproductgrp maintains the group of handlers for detailed product data.
Package vproductgrp maintains the group of handlers for detailed product data.
tooling/docs/output/html
Package html converts the webapi records into html.
Package html converts the webapi records into html.
tooling/docs/output/json
Package json converts the webapi records into json.
Package json converts the webapi records into json.
tooling/docs/output/text
Package text converts the webapi records into text output.
Package text converts the webapi records into text output.
tooling/docs/webapi
Package webapi provides support for extracting web api information from reading the code.
Package webapi provides support for extracting web api information from reading the code.
tooling/logfmt
This program takes the structured log output and makes it readable.
This program takes the structured log output and makes it readable.
tooling/sales-admin
This program performs administrative tasks for the garage sale service.
This program performs administrative tasks for the garage sale service.
tooling/sales-admin/commands
Package commands contains the functionality for the set of commands currently supported by the CLI tooling.
Package commands contains the functionality for the set of commands currently supported by the CLI tooling.
business
core/crud/delegate
Package delegate provides the ability to make function calls between different core packages when an import is not possible.
Package delegate provides the ability to make function calls between different core packages when an import is not possible.
core/crud/home
Package home provides a business access to home data in the system.
Package home provides a business access to home data in the system.
core/crud/home/stores/homedb
Package homedb contains home related CRUD functionality.
Package homedb contains home related CRUD functionality.
core/crud/product
Package product provides an example of a core business API.
Package product provides an example of a core business API.
core/crud/product/stores/productdb
Package productdb contains product related CRUD functionality.
Package productdb contains product related CRUD functionality.
core/crud/user
Package user provides an example of a core business API.
Package user provides an example of a core business API.
core/crud/user/stores/usercache
Package usercache contains user related CRUD functionality with caching.
Package usercache contains user related CRUD functionality with caching.
core/crud/user/stores/userdb
Package userdb contains user related CRUD functionality.
Package userdb contains user related CRUD functionality.
core/views/vproduct
Package vproduct provides an example of a core business API that is based on a view.
Package vproduct provides an example of a core business API that is based on a view.
core/views/vproduct/stores/vproductdb
Package vproductdb provides access to the product view.
Package vproductdb provides access to the product view.
data/dbtest
Package dbtest contains supporting code for running tests that hit the DB.
Package dbtest contains supporting code for running tests that hit the DB.
data/migrate
Package migrate contains the database schema, migrations and seeding data.
Package migrate contains the database schema, migrations and seeding data.
data/sqldb
Package sqldb provides support for access the database.
Package sqldb provides support for access the database.
data/sqldb/dbarray
Package dbarray provides support for database array types.
Package dbarray provides support for database array types.
data/transaction
Package transaction provides support for database transaction related functionality.
Package transaction provides support for database transaction related functionality.
web/auth
Package auth provides authentication and authorization support.
Package auth provides authentication and authorization support.
web/debug
Package debug provides handler support for the debugging endpoints.
Package debug provides handler support for the debugging endpoints.
web/errs
Package errs provides types and support related to web error functionality.
Package errs provides types and support related to web error functionality.
web/metrics
Package metrics constructs the metrics the application will track.
Package metrics constructs the metrics the application will track.
web/mid
Package mid contains the set of middleware functions.
Package mid contains the set of middleware functions.
web/mux
Package mux provides support to bind domain level routes to the application mux.
Package mux provides support to bind domain level routes to the application mux.
web/order
Package order provides support for describing the ordering of data.
Package order provides support for describing the ordering of data.
web/page
Package page provides support for query paging.
Package page provides support for query paging.
foundation
docker
Package docker provides support for starting and stopping docker containers for running tests.
Package docker provides support for starting and stopping docker containers for running tests.
keystore
Package keystore implements the auth.KeyLookup interface.
Package keystore implements the auth.KeyLookup interface.
logger
Package logger provides support for initializing the log system.
Package logger provides support for initializing the log system.
validate
Package validate contains the support for validating models.
Package validate contains the support for validating models.
web
Package web contains a small web framework extension.
Package web contains a small web framework extension.
worker
Package worker manages a set of registered jobs that execute on demand.
Package worker manages a set of registered jobs that execute on demand.
zarf
keys
Package keys stores development public/private key pairs used by the service.
Package keys stores development public/private key pairs used by the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL