mirror of
https://github.com/hanzoai/compute.git
synced 2026-10-30 14:50:41 +00:00
Swap the upstream xorm.io/xorm engine/session types for github.com/hanzoai/orm/relational across the object layer (adapter, stores, and every model) -- relational.Engine/Session/NewEngine in place of the xorm equivalents. go.mod pulls hanzoai/orm v0.6.4 over hanzoai/xorm v1.4.3; go.sum completed. go build ./... is clean. Not closed out: object tests panic on "sql: Register called twice for driver sqlite" -- hanzoai/orm and modernc.org/sqlite both register the "sqlite" driver name; needs a single registration before this can merge.
46 lines
2.0 KiB
Go
46 lines
2.0 KiB
Go
// Copyright 2024 Hanzo Industries Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package object
|
|
|
|
import "github.com/hanzoai/orm/relational"
|
|
|
|
// pgStore serves every owner from one shared engine -- the historical visor
|
|
// backend. owner is ignored: tenant isolation is a WHERE owner=? clause, not a
|
|
// separate database. This is the default provider and keeps the live path
|
|
// byte-identical to before the Base seam existed.
|
|
type pgStore struct {
|
|
engine *relational.Engine
|
|
}
|
|
|
|
func (s *pgStore) EngineFor(string) (*relational.Engine, error) { return s.engine, nil }
|
|
|
|
// Shared is the same one engine -- the shared tables are plain rows in it.
|
|
func (s *pgStore) Shared() *relational.Engine { return s.engine }
|
|
|
|
// PullSharedLeases / PushShared are no-ops under Postgres: the shared engine already
|
|
// IS the single, durable, linearizable coordination store, so the insert-once lease PK
|
|
// holds cluster-wide with no hydrate/ship. (These exist only so the Base backend can
|
|
// make its pod-local `_global` SQLite coord cluster-safe across a leadership handoff.)
|
|
func (s *pgStore) PullSharedLeases() error { return nil }
|
|
func (s *pgStore) PushShared() error { return nil }
|
|
|
|
// AllEngines is the single engine: it already holds every org's rows, so a
|
|
// cross-org sweep is one query against it.
|
|
func (s *pgStore) AllEngines() ([]*relational.Engine, error) {
|
|
return []*relational.Engine{s.engine}, nil
|
|
}
|
|
|
|
func (s *pgStore) Close() error { return s.engine.Close() }
|