mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
93 lines
2.7 KiB
Go
93 lines
2.7 KiB
Go
package sqlite
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"errors"
|
|
|
|
"go.temporal.io/server/common/persistence/sql/sqlplugin"
|
|
)
|
|
|
|
const (
|
|
createEndpointsTableVersionQry = `INSERT INTO nexus_endpoints_partition_status(version) VALUES(1)`
|
|
incrementEndpointsTableVersionQry = `UPDATE nexus_endpoints_partition_status SET version = ? WHERE version = ?`
|
|
getEndpointsTableVersionQry = `SELECT version FROM nexus_endpoints_partition_status`
|
|
|
|
createEndpointQry = `INSERT INTO nexus_endpoints(id, data, data_encoding, version) VALUES (?, ?, ?, 1)`
|
|
updateEndpointQry = `UPDATE nexus_endpoints SET data = ?, data_encoding = ?, version = ? WHERE id = ? AND version = ?`
|
|
deleteEndpointQry = `DELETE FROM nexus_endpoints WHERE id = ?`
|
|
getEndpointByIdQry = `SELECT id, data, data_encoding, version FROM nexus_endpoints WHERE id = ?`
|
|
getEndpointsQry = `SELECT id, data, data_encoding, version FROM nexus_endpoints WHERE id > ? LIMIT ?`
|
|
)
|
|
|
|
func (mdb *db) InitializeNexusEndpointsTableVersion(ctx context.Context) (sql.Result, error) {
|
|
return mdb.conn.ExecContext(ctx, createEndpointsTableVersionQry)
|
|
}
|
|
|
|
func (mdb *db) IncrementNexusEndpointsTableVersion(
|
|
ctx context.Context,
|
|
lastKnownTableVersion int64,
|
|
) (sql.Result, error) {
|
|
return mdb.conn.ExecContext(ctx, incrementEndpointsTableVersionQry, lastKnownTableVersion+1, lastKnownTableVersion)
|
|
}
|
|
|
|
func (mdb *db) GetNexusEndpointsTableVersion(ctx context.Context) (int64, error) {
|
|
var version int64
|
|
err := mdb.conn.GetContext(ctx, &version, getEndpointsTableVersionQry)
|
|
if errors.Is(err, sql.ErrNoRows) {
|
|
return 0, nil
|
|
}
|
|
return version, err
|
|
}
|
|
|
|
func (mdb *db) InsertIntoNexusEndpoints(
|
|
ctx context.Context,
|
|
row *sqlplugin.NexusEndpointsRow,
|
|
) (sql.Result, error) {
|
|
return mdb.conn.ExecContext(
|
|
ctx,
|
|
createEndpointQry,
|
|
row.ID,
|
|
row.Data,
|
|
row.DataEncoding)
|
|
}
|
|
|
|
func (mdb *db) UpdateNexusEndpoint(
|
|
ctx context.Context,
|
|
row *sqlplugin.NexusEndpointsRow,
|
|
) (sql.Result, error) {
|
|
return mdb.conn.ExecContext(
|
|
ctx,
|
|
updateEndpointQry,
|
|
row.Data,
|
|
row.DataEncoding,
|
|
row.Version+1,
|
|
row.ID,
|
|
row.Version)
|
|
}
|
|
|
|
func (mdb *db) DeleteFromNexusEndpoints(
|
|
ctx context.Context,
|
|
id []byte,
|
|
) (sql.Result, error) {
|
|
return mdb.conn.ExecContext(ctx, deleteEndpointQry, id)
|
|
}
|
|
|
|
func (mdb *db) GetNexusEndpointByID(
|
|
ctx context.Context,
|
|
id []byte,
|
|
) (*sqlplugin.NexusEndpointsRow, error) {
|
|
var row sqlplugin.NexusEndpointsRow
|
|
err := mdb.conn.GetContext(ctx, &row, getEndpointByIdQry, id)
|
|
return &row, err
|
|
}
|
|
|
|
func (mdb *db) ListNexusEndpoints(
|
|
ctx context.Context,
|
|
request *sqlplugin.ListNexusEndpointsRequest,
|
|
) ([]sqlplugin.NexusEndpointsRow, error) {
|
|
var rows []sqlplugin.NexusEndpointsRow
|
|
err := mdb.conn.SelectContext(ctx, &rows, getEndpointsQry, request.LastID, request.Limit)
|
|
return rows, err
|
|
}
|