hashServerName creates a consistent hash of the server name for advisory locking We use FNV-1a hash and mask to 63 bits to fit in PostgreSQL's bigint range
(name string)
| 779 | // hashServerName creates a consistent hash of the server name for advisory locking |
| 780 | // We use FNV-1a hash and mask to 63 bits to fit in PostgreSQL's bigint range |
| 781 | func hashServerName(name string) int64 { |
| 782 | const ( |
| 783 | offset64 = 14695981039346656037 |
| 784 | prime64 = 1099511628211 |
| 785 | ) |
| 786 | hash := uint64(offset64) |
| 787 | for i := 0; i < len(name); i++ { |
| 788 | hash ^= uint64(name[i]) |
| 789 | hash *= prime64 |
| 790 | } |
| 791 | return int64(hash & 0x7FFFFFFFFFFFFFFF) |
| 792 | } |
| 793 | |
| 794 | // GetCurrentLatestVersion retrieves the current latest version of a server by server name |
| 795 | func (db *PostgreSQL) GetCurrentLatestVersion(ctx context.Context, tx pgx.Tx, serverName string) (*apiv0.ServerResponse, error) { |
no outgoing calls
no test coverage detected
searching dependent graphs…