-
Notifications
You must be signed in to change notification settings - Fork 14
v0 Breaking Changes
A description of breaking changes introduced in v0
of sysl-go
and their remediation measures.
- v0.1.0 - Build metadata
- v0.5.0 - Error mapping
- v0.13.0 - Load config
- v0.17.0 - Config validator
- v0.28.0 - GRPC interceptor
https://github.com/anz-bank/sysl-go/releases/tag/v0.1.0 - 4e7e986
Introduces build metadata within sysl-go
.
- Remove metadata parameter from
core.Server
// old
core.Server(ctx, name, handler, grpc, logger, registry, buildMetadata)
// new
core.Server(ctx, name, handler, grpc, logger, registry)
- Move build flags to
core
namespace
# old
go build -ldflags="-X main.Name=foo"
# new
go build -ldflags "-X github.com/anz-bank/sysl-go/core.Name=foo"
https://github.com/anz-bank/sysl-go/releases/tag/v0.5.0 - d749e18
This change does the following:
- Introduce error types defined in
sysl
- Change the interaction between the framework and custom code to support internal error handling.
-
Upgrade
sysl
tov0.42.0
or above. -
Change
RestGenCallback
HandleError
toMapError
// old
// HandleError allows custom HTTP errors to be added to `sys-go` errors
HandleError(ctx context.Context, w http.ResponseWriter, kind common.Kind, message string, cause error)
// new
// MapError maps an error to an HTTPError in instances where custom error mapping is
// required. Return nil to perform default error mapping; defined as:
// 1. CustomError.HTTPError if the original error is a CustomError, otherwise
// 2. common.MapError
MapError(ctx context.Context, err error) *common.HTTPError
Please note that the err
passed through is currently guaranteed to be a ServerError
however this is subject to change.
- Replace custom error handling with
sysl
errors (optional)
!type BusinessLogicError [~error]:
http_status <: string [value = "500"]
http_code <: string [value = "1001"]
http_message <: string [value = "Business logic error"]
Errors defined in sysl
can be used an as error
and will automatically be mapped to an appropriate HTTPError
if nil
is returned from MapError
.
This change does the following:
- Renames
config.ReadConfig
toconfig.LoadConfig
. - Validates the loaded config with
validator.Validate
.
- Change calls from
config.ReadConfig
toconfig.LoadConfig
.
https://github.com/anz-bank/sysl-go/releases/tag/v0.17.0 - eedeba9
The current declaration of Config
instances within sysl-go
have a requirement that they are validator.Validator
instances. This removes the necessity for config to be a validator.
This change does the following:
- Change
Config
return type inhandlerinitialiser.HandlerInitialiser
interface. - Change
Config
return type incore.RestGenCallback
interface
- Update
Config
inhandlerinitialiser.HandlerInitialiser
.
// old:
type HandlerInitialiser interface
Config() validator.Validator
}
// new:
type HandlerInitialiser interface {
Config() interface{}
}
- Update
Config
incore.RestGenCallback
.
// old:
type RestGenCallback interface {
Config() validator.Validator
}
// new:
type RestGenCallback interface {
Config() interface{}
}
https://github.com/anz-bank/sysl-go/releases/tag/v0.28.0 - 453f8db
This change does the following:
- Adds the
Interceptors
method to thecore.GrpcManager
interface.
- Add the
Interceptors
method to thecore.GrpcManager
implementation.
func (h *CustomGrpcManager) Interceptors() []grpc.UnaryServerInterceptor {
return []grpc.UnaryServerInterceptor{}
}
Separates admin server and config from REST and GRPC managers.
This change does the following:
- Renames
Manager
toRestManager
. - Renames
HandlerInitialiser
toRestHandlerInitialiser
. - Moves
LibraryConfig
fromRestManager
(previouslyManager
) tocore.Server
argument. - Moves the
AdminServerConfig
fromRestManager
(previouslyManager
) toLibraryConfig
.
- Fix compilation issues due to
HandlerInitialiser
rename:
// old
func (h *HandlerManager) EnabledHandlers() []handlerinitialiser.HandlerInitialiser { ... }
// new
func (h *HandlerManager) EnabledHandlers() []handlerinitialiser.RestHandlerInitialiser { ... }
- Pass
LibraryConfig
intocore.Server
:
// old
func Server(
ctx context.Context,
name string,
rest RestManager,
grpc GrpcManager,
logger *logrus.Logger,
prom *prometheus.Registry)
// new
func Server(
ctx context.Context,
name string,
cfg *config.LibraryConfig // new
rest RestManager,
grpc GrpcManager,
logger *logrus.Logger,
prom *prometheus.Registry)
- Move
adminServer
config toconfig.yaml
root:
# old
server: # or other custom name
adminServer:
contextTimeout: 2s
http:
basePath: /admin
...
# new
adminServer:
contextTimeout: 2s
http:
basePath: /admin
...