Skip to content

Releases: kodefluence/monorepo

v1.3.1 Regenerate mock for DB package

16 Dec 14:01
Compare
Choose a tag to compare

Highlight

Re-generate mock for db package

v1.3.0 small addition to db package

16 Dec 14:00
ba5b1b0
Compare
Choose a tag to compare

Highlight

We're adding new method into db package to eject adapted *sql.DB, in some usecase this would be helpful.

Changes

Added

DB

Easily eject adapted sql.DB

sql := db.Adapt(sqldb)
sqldb = sql.Eject()

v1.2.0 small addition to jsonapi package

04 Sep 13:20
Compare
Choose a tag to compare

Highlight

We're adding new method into jsonapi package to make easier assign set of errors into jsonapi body.

Changes

Added

JSONAPI

WithErrors jsonapi option. This method however would not assign error if the errors is already in the response.

jsonapi.BuildResponse(jsonapi.WithErrors(response.Errors))

v1.1.0 codefluence-x renaming, jsonapi package and other additional feature

31 Aug 16:29
Compare
Choose a tag to compare

Highlight

  1. Change codefluence-x branding into kodefluence
  2. New jsonapi package which follow the standards of https://jsonapi.org.
  3. More exception type

Change diff.

Important Notes

We're change our package name into kodefluence. This would be full rebranding for all of our repository and others.


Changes

Added

JSONAPI

jsonapi work as a standard grpc or http response. Usage:

Create new json response.

jsonapi.BuildResponse(jsonapi.WithData(map[string]interface{}{
    "name": "testing",
}))

It would results with this output

{"data":{"name":"testing"}}

Create new json error response with exception

exc1 := exception.Throw(
	errors.New("unexpected error"),
	exception.WithDetail("detail"),
	exception.WithTitle("title"),
)

exc2 := exception.Throw(
	errors.New("unexpected error"),
	exception.WithDetail("detail_2"),
	exception.WithTitle("title_2"),
)

jsonapi.BuildResponse(
	jsonapi.WithException("ERR401", http.StatusNotFound, exc1),
	jsonapi.WithExceptionMeta("ERR401", http.StatusNotFound, exc2, jsonapi.Meta{
		"sample": "sample",
	}),
	jsonapi.WithMeta("show_error", true),
)

Exception

Create 2 new exception, to support more dynamic exception error.

exception.Unauthorized
exception.Forbidden

DB

Add new GetInstance method to get previously defined databases.

sqldb, err = db.FabricateMySQL("main_db", config, db.WithConnMaxLifetime(time.Second), db.WithMaxIdleConn(100), db.WithMaxOpenConn(100))
sqldbvalue, err := db.GetInstance("main_db")

v1.0.1 Bug Fix

10 Feb 16:47
Compare
Choose a tag to compare

Create new mock package for DB.

Monorepo 1.0.0

10 Feb 15:38
c685992
Compare
Choose a tag to compare

v1.0.0 is Here!

In this version you could use some of the packages that we're developing which we will describe in this release:

Command

Command is a wrapper for cobra.Command. Usage:

// fabricating command
cmd := command.Fabricate(command.Config{
	Name:  "altair",
	Short: "Open Source API-Gateway",
})

DB

DB is a wrapper for any sql.DB which support better unit test functionality and centralized connection control.

// fabricating db
config := db.Config{
	Username: "root",
	Password: "rootpw",
	Host:     "localhost",
	Port:     "3306",
	Name:     "test_database",
}

sqldb, err := db.FabricateMySQL("main_db", config, db.WithConnMaxLifetime(time.Second), db.WithMaxIdleConn(100), db.WithMaxOpenConn(100))


// next time you open connection, it will return previously created connection instead of creating a new one
sqldb, err := db.FabricateMySQL("main_db", config, db.WithConnMaxLifetime(time.Second), db.WithMaxIdleConn(100), db.WithMaxOpenConn(100))


// close all database connection
db.CloseAll()

MemoryStore

MemoryStore is a wrapper for any cache implementation, currently only supporting memcached. But in the future it will also support redis, keydb and other helpful stack.

// fabricate new memcached
memcached := memorystore.FabricateMemcached("main_cache", memorystore.Config{})

Exception

Golang rich error wrapper

// throw new exception

err := errors.New("unexpected error")
exceptionType := exception.NotFound
detail := "data not found in the databases because of deletion"
title := "data is not exists"

exc := exception.Throw(err, exception.WithType(exceptionType), exception.WithTitle(title), exception.WithDetail(detail))


if exc.Type() == exception.NotFound {
  fmt.Println("The data is not found")
}

Context

Golang rich context wrapper

// create new kontext
ctx := context.Background()
ktx := kontext.Fabricate(kontext.WithDefaultContext(ctx))

// pass context in your function and it will keep the variable it gets along the way
key := "some-value"
val := 100
ktx.Set(key, val)

returnedValue, exists := ktx.Get(key)

What's Next?

  1. Distributed rate limiter package
  2. In-app Queue
  3. In-app Cronjob