registry

package
v0.0.0-...-6b1c1c1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 11 Imported by: 0

README

Registry

Dependency Injection(DI)の実装。
各層で実装している構造体の依存解決を解決する。

テンプレート

package registry

import (
	"github.com/16francs/gran/api/sample/internal/application"
	rv "github.com/16francs/gran/api/sample/internal/application/validation"
	"github.com/16francs/gran/api/sample/internal/domain/service"
	"github.com/16francs/gran/api/sample/internal/infrastructure/persistence"
	dv "github.com/16francs/gran/api/sample/internal/infrastructure/validation"
	v1 "github.com/16francs/gran/api/sample/internal/interface/handler/v1"
	"github.com/16francs/gran/api/sample/lib/firebase/authentication"
	"github.com/16francs/gran/api/sample/lib/firebase/firestore"
)

// Registry - DIコンテナ
type Registry struct {
	V1Health v1.APIV1HealthHandler
	V1Sample   v1.APIV1SampleHandler
}

// NewRegistry - internalディレクトリのファイルを読み込み
func NewRegistry(fa *authentication.Auth, fs *firestore.Firestore) *Registry {
	v1Health := v1HealthInjection()
	v1Sample := v1SampleInjection(fa, fs)

	return &Registry{
		V1Sample:   v1Sample,
		V1Health: v1Health,
	}
}

func v1HealthInjection() v1.APIV1HealthHandler {
	hh := v1.NewAPIV1HealthHandler()

	return hh
}

func v1SampleInjection(fa *authentication.Auth, fs *firestore.Firestore) v1.APIV1SampleHandler {
	sp := persistence.NewSamplePersistence(fa, fs)
	sdv := dv.NewSampleDomainValidation(sp)
	ss := service.NewSampleService(sdv, sp)
	srv := rv.NewSampleRequestValidation()
	su := application.NewSampleApplication(srv, ss)
	sh := v1.NewAPIV1SampleHandler(su)

	return uh
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func V1UserInjection

func V1UserInjection(fa *authentication.Auth, fs *firestore.Firestore, cs *gcs.Storage) v1.APIV1UserHandler

V1UserInjection - v1 User関連の依存関係を記載

Types

type Registry

type Registry struct {
	Health handler.APIHealthHandler
	V1User v1.APIV1UserHandler
}

Registry - DIコンテナ

func NewRegistry

func NewRegistry(fa *authentication.Auth, fs *firestore.Firestore, cs *storage.Storage) *Registry

NewRegistry - internalディレクトリのファイルを読み込み

Jump to

Keyboard shortcuts

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