| 28 | var _ database.Database = (*PostgresInstance)(nil) |
| 29 | |
| 30 | func (p *PostgresInstance) Close() error { |
| 31 | p.closeOnce.Do(func() { |
| 32 | var errs []error |
| 33 | |
| 34 | if p.Postgres != nil { |
| 35 | errs = append(errs, p.Postgres.Close()) |
| 36 | } |
| 37 | |
| 38 | if p.container != nil { |
| 39 | terminateCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| 40 | defer cancel() |
| 41 | errs = append(errs, p.container.Terminate(terminateCtx)) |
| 42 | } |
| 43 | |
| 44 | p.closeErr = errors.Join(errs...) |
| 45 | }) |
| 46 | |
| 47 | return p.closeErr |
| 48 | } |
| 49 | |
| 50 | func (p *PostgresInstance) GetEngineType() string { |
| 51 | return p.Postgres.GetEngineType() |