mirror of
https://github.com/hanzoai/replicate.git
synced 2026-10-30 18:23:20 +00:00
* chore: add .dockerignore * ci: migrate to canonical hanzoai/.github/docker-build.yml reusable * fork: switch to hanzoai/lz4 + hanzoai/ltx (pin v4.1.22 lz4 wire format) pierrec/lz4/v4 v4.1.23+ broke end-of-frame detection causing superfly/ltx (and replicate's verify path) to fail with 'expected lz4 end frame'. We now own the lz4 + ltx forks at hanzoai/lz4 and hanzoai/ltx, pinned to the working v4.1.22 wire format. All tests passing.
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"log/slog"
|
|
|
|
"github.com/hanzoai/ltx"
|
|
|
|
"github.com/hanzoai/replicate"
|
|
)
|
|
|
|
var _ replicate.ReplicaClient = (*ReplicaClient)(nil)
|
|
|
|
type ReplicaClient struct {
|
|
InitFunc func(ctx context.Context) error
|
|
DeleteAllFunc func(ctx context.Context) error
|
|
LTXFilesFunc func(ctx context.Context, level int, seek ltx.TXID, useMetadata bool) (ltx.FileIterator, error)
|
|
OpenLTXFileFunc func(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error)
|
|
WriteLTXFileFunc func(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, r io.Reader) (*ltx.FileInfo, error)
|
|
DeleteLTXFilesFunc func(ctx context.Context, a []*ltx.FileInfo) error
|
|
}
|
|
|
|
func (c *ReplicaClient) Type() string { return "mock" }
|
|
|
|
func (c *ReplicaClient) Init(ctx context.Context) error {
|
|
if c.InitFunc != nil {
|
|
return c.InitFunc(ctx)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *ReplicaClient) DeleteAll(ctx context.Context) error {
|
|
return c.DeleteAllFunc(ctx)
|
|
}
|
|
|
|
func (c *ReplicaClient) LTXFiles(ctx context.Context, level int, seek ltx.TXID, useMetadata bool) (ltx.FileIterator, error) {
|
|
return c.LTXFilesFunc(ctx, level, seek, useMetadata)
|
|
}
|
|
|
|
func (c *ReplicaClient) OpenLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error) {
|
|
return c.OpenLTXFileFunc(ctx, level, minTXID, maxTXID, offset, size)
|
|
}
|
|
|
|
func (c *ReplicaClient) WriteLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, r io.Reader) (*ltx.FileInfo, error) {
|
|
return c.WriteLTXFileFunc(ctx, level, minTXID, maxTXID, r)
|
|
}
|
|
|
|
func (c *ReplicaClient) DeleteLTXFiles(ctx context.Context, a []*ltx.FileInfo) error {
|
|
return c.DeleteLTXFilesFunc(ctx, a)
|
|
}
|
|
|
|
func (c *ReplicaClient) SetLogger(_ *slog.Logger) {}
|