Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
agourdel committed Feb 21, 2024
1 parent e6c0cad commit baf8930
Show file tree
Hide file tree
Showing 18 changed files with 274 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*.dll
*.so
*.dylib

.vscode
# Test binary, built with `go test -c`
*.test

Expand Down
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# Go-KGPKernel
# Go-KGPKernel
Go Virgin "ready-to-development-scale" Kernel for organizations following the Ker-G Pattern

---

## Kernel's boundaries

- The KGP Kernel's goal is to contain all of the business code of an application.
- The KGP Kernel is agnostic of the context of use.
- The Contextual Application (Web App, CLI, Desktop application, etc..) that uses the Kernel has to provide it with access to configuration attributes, external providers and the data persistence layer by implementing the interfaces *IConfigsManager*, *IProvidersManager* and *IRepositoriesManager*.


---

## Layers' boundaries

- Roles, Domains and Services are the layers of the kernel.
- Roles, Domains and Services are each designed to be respectively developed in isolation from other objects of the same layer.

- Roles are designed to be easily developped by different developpers in the same Kernel Repo.
- Roles can make calls to Domains and Services.

- Domains are designed to be developped outside the Kernel Repo (In order to be reused by different kernels) as well as inside the Kernel Repo.
- Domains are Roles-agnostic and can make calls to Services.
- Domains may have private Subdomains.

- Services are Roles-agnostic and domains-agnostics.
- Services are encapsulation for external service providers, external domains (Micro-services) and "domains" whose purpose is to serve other domains.

## Tips for getting started

From Scratch :
- Copy/Past */Domains/_FooDomain* and start to develop domains.
- Copy/Past */Services/_ExampleService* each time a domain need one.

*more to come...*

---

### Contact

Do you want to know more about the KGP Kernel and the Ker-G Pattern?
Please feel free to ping me at [@AlexandreGrdl](https://twitter.com/AlexandreGrdl "@AlexandreGrdl")
9 changes: 9 additions & 0 deletions domains/domainsmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package domains

import (
"agourdel.com/kgpkernel/domains/foodomain"
)

type DomainsManager struct {
FooActions foodomain.FooActions
}
24 changes: 24 additions & 0 deletions domains/foodomain/config/fooconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package config

type FooConfig struct {
FirstValue int64
SecondValue string
}

func NewDefautFooConfig() *FooConfig {
defautConfig := &FooConfig{
FirstValue: 42,
SecondValue: "Defaut",
}

return defautConfig
}

func NewFooConfig(firstValue int64, secondValue string) *FooConfig {
fooConfig := &FooConfig{
FirstValue: firstValue,
SecondValue: secondValue,
}

return fooConfig
}
24 changes: 24 additions & 0 deletions domains/foodomain/fooactions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package foodomain

import (
"agourdel.com/kgpkernel/domains/foodomain/config"
"agourdel.com/kgpkernel/domains/foodomain/interfaces"


)

type FooActions struct {
fooConfig config.FooConfig
fooRepositories interfaces.IFooRepositories
fooService1 interfaces.IFooService1
}

func newFooActions(fooConfig config.FooConfig, fooRepositories interfaces.IFooRepositories, fooService1 interfaces.IFooService1) *FooActions {
mFooActions := &FooActions{
fooConfig: fooConfig,
fooRepositories: fooRepositories,
fooService1: fooService1,
}

return mFooActions
}
9 changes: 9 additions & 0 deletions domains/foodomain/interfaces/ifoorepositories.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package interfaces

import (
"agourdel.com/kgpkernel/domains/foodomain/models"
)

type IFooRepositories interface {
GetVirgins() []models.VirginModel
}
4 changes: 4 additions & 0 deletions domains/foodomain/interfaces/ifooservice1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package interfaces

type IFooService1 interface {
}
4 changes: 4 additions & 0 deletions domains/foodomain/models/virginmodel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package models

type VirginModel struct {
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module agourdel.com/kgpkernel

go 1.22.0
11 changes: 11 additions & 0 deletions interfaces/iconfigsmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package interfaces

import(
FooConfig "agourdel.com/kgpkernel/domains/foodomain/config"
ExampleConfig "agourdel.com/kgpkernel/services/exampleservice/config"
)

type IConfigsManager struct {
FooConfig FooConfig.FooConfig
ExampleConfig ExampleConfig.ExampleConfig
}
9 changes: 9 additions & 0 deletions interfaces/iprovidersmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package interfaces

import(
ExampleInterfaces "agourdel.com/kgpkernel/services/exampleservice/interfaces"
)

type IProvidersManager struct {
ExampleProvider ExampleInterfaces.IExampleProvider
}
9 changes: 9 additions & 0 deletions interfaces/irepositoriesmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package interfaces

import (
FooInterfaces "agourdel.com/kgpkernel/domains/foodomain/interfaces"
)

type IRepositoriesManager struct {
FooRepositories FooInterfaces.IFooRepositories
}
39 changes: 39 additions & 0 deletions kgpkernel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package kgpkernel

import(
WaldoRole "agourdel.com/kgpkernel/roles/waldorole"
KernelInterfaces "agourdel.com/kgpkernel/interfaces"
KernelServices "agourdel.com/kgpkernel/services"
KernelDomains "agourdel.com/kgpkernel/domains"
)

type Kernel struct {
RepositoriesManager KernelInterfaces.IRepositoriesManager
ProvidersManager KernelInterfaces.IProvidersManager
ConfigManager KernelInterfaces.IConfigsManager
ServicesManager KernelServices.ServicesManager
DomainesManager KernelDomains.DomainsManager
Roles RolesStruct
}


type RolesStruct struct {
WaldoRole WaldoRole.WaldoRole
}


func newKernel(
config KernelInterfaces.IConfigsManager,
repositoriesManager KernelInterfaces.IRepositoriesManager,
providersManager KernelInterfaces.IProvidersManager) *Kernel {

kernel := &Kernel{
RepositoriesManager : repositoriesManager,
ProvidersManager: providersManager,
ConfigManager: config,
ServicesManager: *KernelServices.NewServicesManager(config,providersManager),
}

return kernel

}
13 changes: 13 additions & 0 deletions roles/waldorole/waldoroleusecases.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package waldoroles

import(
KernelServices "agourdel.com/kgpkernel/services"
KernelDomains "agourdel.com/kgpkernel/domains"
KernelInterfaces "agourdel.com/kgpkernel/interfaces"
)

type WaldoRole struct {
configManager KernelInterfaces.IConfigsManager
servicesManager KernelServices.ServicesManager
domainsManager KernelDomains.DomainsManager
}
25 changes: 25 additions & 0 deletions services/exampleservice/config/exampleconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package config


type ExampleConfig struct {
FirstValue int64
SecondValue string
}

func NewDefautExampleConfig() *ExampleConfig {
defautConfig := &ExampleConfig{
FirstValue: 42,
SecondValue: "Defaut",
}

return defautConfig
}

func NewExampleConfig(firstValue int64, secondValue string) *ExampleConfig {
exampleservice := &ExampleConfig{
FirstValue: firstValue,
SecondValue: secondValue,
}

return exampleservice
}
14 changes: 14 additions & 0 deletions services/exampleservice/exampleservice.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package exampleservice

import (
"agourdel.com/kgpkernel/services/exampleservice/config"
"agourdel.com/kgpkernel/services/exampleservice/interfaces"

)

type ExampleService struct {
Config config.ExampleConfig
Provider interfaces.IExampleProvider
}


5 changes: 5 additions & 0 deletions services/exampleservice/interfaces/iexampleprovider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package interfaces

type IExampleProvider struct {

}
28 changes: 28 additions & 0 deletions services/servicesmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package services

import(
KernelInterfaces "agourdel.com/kgpkernel/interfaces"
ExampleService "agourdel.com/kgpkernel/services/exampleservice"
)

type ServicesManager struct {
providersManager KernelInterfaces.IProvidersManager
configsManager KernelInterfaces.IConfigsManager
ExampleService ExampleService.ExampleService
}

func NewServicesManager(
configsManager KernelInterfaces.IConfigsManager,
providersManager KernelInterfaces.IProvidersManager) *ServicesManager {

servicesManager := &ServicesManager{
providersManager: providersManager,
configsManager: configsManager,
ExampleService: ExampleService.ExampleService{
Config:configsManager.ExampleConfig,
Provider:providersManager.ExampleProvider,
},
}

return servicesManager
}

0 comments on commit baf8930

Please sign in to comment.