mirror of
https://github.com/holos-run/holos.git
synced 2026-03-20 17:25:01 +00:00
Add Tilt back from holos server Note with this patch the ec-creds.yaml file needs to be applied to the provisioner and an external secret used to sync the image pull creds. With this patch the dev instance is accessible behind the auth proxy. pgAdmin also works from the Tilt UI. https://jeff.holos.dev.k2.ois.run/app/start
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
// Package handler implements service handlers. Handlers are not bound to a
|
|
// specific server transport like http or nats, instead they take a context and
|
|
// a request proto buf as inputs. http and other transports.
|
|
//
|
|
// New handler constructors are expected to take in dependencies provided by
|
|
// other packages like connected database clients, loggers, tracers, etc...
|
|
package handler
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log/slog"
|
|
|
|
"github.com/holos-run/holos/internal/ent"
|
|
)
|
|
|
|
// WithTx runs callbacks in a transaction as described in https://entgo.io/docs/transactions/#best-practices
|
|
func WithTx(ctx context.Context, client *ent.Client, fn func(tx *ent.Tx) error) error {
|
|
tx, err := client.Tx(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer func() {
|
|
if v := recover(); v != nil {
|
|
slog.ErrorContext(ctx, "panic", "v", v)
|
|
_ = tx.Rollback()
|
|
panic(v)
|
|
}
|
|
}()
|
|
if err := fn(tx); err != nil {
|
|
if rerr := tx.Rollback(); rerr != nil {
|
|
err = fmt.Errorf("%w: rolling back transaction: %v", err, rerr)
|
|
}
|
|
return err
|
|
}
|
|
if err := tx.Commit(); err != nil {
|
|
return fmt.Errorf("committing transaction: %w", err)
|
|
}
|
|
return nil
|
|
}
|