Procyon|Docs
ComponentsLifecycle

Disposal

Release resources when the application shuts down.

Implement component.Disposable when a singleton owns resources that must be closed.

database.go
type Database struct {
	conn *sql.DB
}

func (d *Database) Dispose() error {
	return d.conn.Close()
}

Use disposal for resources owned by the component:

  • database connections
  • background workers
  • file handles
  • client pools
  • watchers or subscriptions

Do not dispose resources the component does not own. If the resource was passed in from another component, the owner should handle cleanup.