Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
Refactor structure and API
Browse files Browse the repository at this point in the history
- Introduce use case specific interface
- Introduce generic event mechanism
  • Loading branch information
DerAndereAndi authored Feb 24, 2024
2 parents 78ea63e + 4f95add commit 23dc02d
Show file tree
Hide file tree
Showing 167 changed files with 12,882 additions and 7,574 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ jobs:
skip-build-cache: true

- name: Test
run: go test -race -v -coverprofile=coverage.out -covermode=atomic ./...
run: go test -race -v -coverprofile=coverage_temp.out -covermode=atomic ./...

- name: Remove mocks and cmd from coverage
run: grep -v -e "/cemd/mocks/" -e "/cemd/cmd/" coverage_temp.out > coverage.out

- name: Send coverage
uses: coverallsapp/github-action@v2
Expand Down
10 changes: 10 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
with-expecter: true
inpackage: false
dir: "{{ .InterfaceDir }}/mocks/"
mockname: "{{.InterfaceName}}"
outpkg: "mocks"
filename: "{{.InterfaceName}}.go"
all: true
packages:
github.com/enbility/cemd/api:
github.com/enbility/cemd/evsecc:
53 changes: 47 additions & 6 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
package api

import (
shipapi "github.com/enbility/ship-go/api"
spineapi "github.com/enbility/spine-go/api"
"github.com/enbility/spine-go/model"
)

// Implemented by *Solutions, used by Cem
type SolutionInterface interface {
RegisterRemoteDevice(details *shipapi.ServiceDetails, dataProvider any) any
UnRegisterRemoteDevice(remoteDeviceSki string)
//go:generate mockery

// Implemented by CEM
type CemInterface interface {
// Setup the EEBUS service
Setup() error

// Start the EEBUS service
Start()

// Shutdown the EEBUS service
Shutdown()

// Add a use case implementation
AddUseCase(usecase UseCaseInterface)
}

// Implemented by each UseCase
type UseCaseInterface interface {
// provide the usecase name
UseCaseName() model.UseCaseNameType

// add the features
AddFeatures()
AddUseCases()

// add the usecase
AddUseCase()

// returns if the entity supports the usecase
//
// possible errors:
// - ErrDataNotAvailable if that information is not (yet) available
// - and others
IsUseCaseSupported(remoteEntity spineapi.EntityRemoteInterface) (bool, error)
}

// interface for informing the cem about specific events
// for each supported usecase
//
// UseCaseEventType values can be found in the api definition of each
// supported usecase
//
// implemented by the actual CEM, used by UCEvseCCInterface implementation
type UseCaseEventReaderInterface interface {
// Inform about a new usecase specific event
SpineEvent(ski string, entity spineapi.EntityRemoteInterface, event UseCaseEventType)
}
Loading

0 comments on commit 23dc02d

Please sign in to comment.