Documentation
¶
Index ¶
- Variables
- type CSVProcess
- type ColumnName
- type ConfigJob
- type ContributorAdapter
- type ContributorRecord
- type ContributorRepo
- type FailRecord
- type FailRepository
- type FileProcessor
- type GetFailRecordsResponse
- type GetJobResponse
- type ImportContributorRequest
- type ImportContributorResponse
- type Job
- type ProcessResult
- type ProduceJob
- type Publisher
- type RecordErrType
- type RecordProcessError
- type Repository
- type Service
- func (s Service) CreateImportJob(ctx context.Context, req ImportContributorRequest) (ImportContributorResponse, error)
- func (s Service) GetFailRecords(ctx context.Context, jobID uint) ([]GetFailRecordsResponse, error)
- func (s Service) JobStatus(ctx context.Context, id uint) (GetJobResponse, error)
- func (s Service) ProcessJob(ctx context.Context, jobID uint) error
- type Status
- type ValidateConfig
- type Validator
- type ValidatorJobRepo
- type XLSXProcess
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFailRecordNotFound = errors.New("fail record not found") ErrJobNotExists = errors.New("job not exists") )
Functions ¶
This section is empty.
Types ¶
type CSVProcess ¶
type CSVProcess struct {
// contains filtered or unexported fields
}
func (CSVProcess) Process ¶
func (c CSVProcess) Process(file *os.File) (ProcessResult, error)
type ColumnName ¶
type ColumnName string
var ( GithubID ColumnName = "github_id" GithubUsername ColumnName = "github_username" DisplayName ColumnName = "display_name" ProfileImage ColumnName = "profile_image" Bio ColumnName = "bio" PrivacyMode ColumnName = "privacy_mode" Email ColumnName = "email" )
func (ColumnName) String ¶
func (c ColumnName) String() string
type ContributorAdapter ¶
type ContributorAdapter struct {
// contains filtered or unexported fields
}
func NewContributorAdapter ¶
func NewContributorAdapter(contrSvc ContributorRepo) ContributorAdapter
func (ContributorAdapter) UpsertContributor ¶
func (c ContributorAdapter) UpsertContributor(ctx context.Context, req ContributorRecord) error
type ContributorRecord ¶
type ContributorRepo ¶
type ContributorRepo interface {
Upsert(ctx context.Context, contributor contributor.UpsertContributorRequest) (contributor.UpsertContributorResponse, error)
}
type FailRecord ¶
type FailRepository ¶
type FailRepository interface {
Create(ctx context.Context, failRecord FailRecord) error
GetByJobID(ctx context.Context, jobID uint) ([]FailRecord, error)
}
type FileProcessor ¶
type FileProcessor interface {
Process(file *os.File) (ProcessResult, error)
}
type GetFailRecordsResponse ¶
type GetFailRecordsResponse struct {
ID uint `json:"id"`
JobID uint `json:"job_id"`
RecordNumber int `json:"record_number"`
Reason string `json:"reason"`
RawData []string `json:"raw_data"`
RetryCount int `json:"retry_count"`
LastError string `json:"last_error"`
ErrType RecordErrType `json:"err_type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
}
type GetJobResponse ¶
type GetJobResponse struct {
ID uint `json:"ID"`
TotalRecords int `json:"total_records,omitempty"`
SuccessCount int `json:"success_count,omitempty"`
FailCount int `json:"fail_count,omitempty"`
IdempotencyKey string `json:"idempotency_key"`
FileHash string `json:"file_hash"`
FileName string `json:"file_name"`
FilePath string `json:"file_path"`
Status Status `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
type ProcessResult ¶
type ProcessResult struct {
Total int
Success int
Fail int
SuccessRecords []ContributorRecord
FailRecords []FailRecord
}
type ProduceJob ¶
type RecordErrType ¶
type RecordErrType int
const ( ErrTypeValidation RecordErrType = iota + 1 ErrTypeUnexpected )
type RecordProcessError ¶
type RecordProcessError struct {
Type RecordErrType
Err error
}
func (RecordProcessError) Error ¶
func (e RecordProcessError) Error() string
type Repository ¶
type Repository interface {
CreateJob(ctx context.Context, job Job) (uint, error)
GetJobByIdempotencyKey(ctx context.Context, key string) (*Job, error)
GetJobByFileHash(ctx context.Context, fileHash string) (*Job, error)
GetJobByID(ctx context.Context, ID uint) (Job, error)
UpdateStatus(ctx context.Context, jobID uint, status Status) error
UpdateJob(ctx context.Context, job Job) error
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService( cfg ConfigJob, repo Repository, pub Publisher, contributorAdapter ContributorAdapter, failRecord FailRepository, validator ValidatorJobRepo) Service
func (Service) CreateImportJob ¶
func (s Service) CreateImportJob(ctx context.Context, req ImportContributorRequest) (ImportContributorResponse, error)
func (Service) GetFailRecords ¶
type ValidateConfig ¶
type ValidateConfig struct {
HttpFileType []string `koanf:"http_file_type"`
}
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func (Validator) ImportJobRequestValidate ¶
func (v Validator) ImportJobRequestValidate(req ImportContributorRequest) error
type ValidatorJobRepo ¶
type ValidatorJobRepo interface {
ImportJobRequestValidate(req ImportContributorRequest) error
}
func NewValidator ¶
func NewValidator(cfg ValidateConfig) ValidatorJobRepo
type XLSXProcess ¶
type XLSXProcess struct {
// contains filtered or unexported fields
}
func (XLSXProcess) Process ¶
func (x XLSXProcess) Process(file *os.File) (ProcessResult, error)
Click to show internal directories.
Click to hide internal directories.