Documentation ¶
Overview ¶
Package dgraph is a generated GoMock package.
Package dgraph is a generated GoMock package.
Package dgraph is a generated GoMock package.
Index ¶
- type Client
- func (d *Client) Alter(ctx context.Context, op any) error
- func (d *Client) Connect()
- func (d *Client) HealthCheck(ctx context.Context) (any, error)
- func (d *Client) Mutate(ctx context.Context, mu any) (any, error)
- func (d *Client) NewReadOnlyTxn() any
- func (d *Client) NewTxn() any
- func (d *Client) Query(ctx context.Context, query string) (any, error)
- func (d *Client) QueryWithVars(ctx context.Context, query string, vars map[string]string) (any, error)
- func (d *Client) UseLogger(logger any)
- func (d *Client) UseMetrics(metrics any)
- func (d *Client) UseTracer(tracer any)
- type Config
- type DgraphClient
- type Logger
- type Metrics
- type MockDgraphClient
- func (m *MockDgraphClient) Alter(ctx context.Context, op *api.Operation) error
- func (m *MockDgraphClient) EXPECT() *MockDgraphClientMockRecorder
- func (m *MockDgraphClient) GetJwt() api.Jwt
- func (m *MockDgraphClient) Login(ctx context.Context, userid, password string) error
- func (m *MockDgraphClient) LoginIntoNamespace(ctx context.Context, userid, password string, namespace uint64) error
- func (m *MockDgraphClient) NewReadOnlyTxn() Txn
- func (m *MockDgraphClient) NewTxn() Txn
- func (m *MockDgraphClient) Relogin(ctx context.Context) error
- type MockDgraphClientMockRecorder
- func (mr *MockDgraphClientMockRecorder) Alter(ctx, op any) *gomock.Call
- func (mr *MockDgraphClientMockRecorder) GetJwt() *gomock.Call
- func (mr *MockDgraphClientMockRecorder) Login(ctx, userid, password any) *gomock.Call
- func (mr *MockDgraphClientMockRecorder) LoginIntoNamespace(ctx, userid, password, namespace any) *gomock.Call
- func (mr *MockDgraphClientMockRecorder) NewReadOnlyTxn() *gomock.Call
- func (mr *MockDgraphClientMockRecorder) NewTxn() *gomock.Call
- func (mr *MockDgraphClientMockRecorder) Relogin(ctx any) *gomock.Call
- type MockLogger
- func (m *MockLogger) Debug(args ...any)
- func (m *MockLogger) Debugf(pattern string, args ...any)
- func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
- func (m *MockLogger) Error(args ...any)
- func (m *MockLogger) Errorf(pattern string, args ...any)
- func (m *MockLogger) Log(args ...any)
- func (m *MockLogger) Logf(pattern string, args ...any)
- type MockLoggerMockRecorder
- func (mr *MockLoggerMockRecorder) Debug(args ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Debugf(pattern any, args ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Error(args ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Errorf(pattern any, args ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Log(args ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Logf(pattern any, args ...any) *gomock.Call
- type MockMetrics
- type MockMetricsMockRecorder
- type MockTxn
- func (m *MockTxn) BestEffort() Txn
- func (m *MockTxn) Commit(ctx context.Context) error
- func (m *MockTxn) Discard(ctx context.Context) error
- func (m *MockTxn) Do(ctx context.Context, req *api.Request) (*api.Response, error)
- func (m *MockTxn) EXPECT() *MockTxnMockRecorder
- func (m *MockTxn) Mutate(ctx context.Context, mu *api.Mutation) (*api.Response, error)
- func (m *MockTxn) Query(ctx context.Context, q string) (*api.Response, error)
- func (m *MockTxn) QueryRDF(ctx context.Context, q string) (*api.Response, error)
- func (m *MockTxn) QueryRDFWithVars(ctx context.Context, q string, vars map[string]string) (*api.Response, error)
- func (m *MockTxn) QueryWithVars(ctx context.Context, q string, vars map[string]string) (*api.Response, error)
- type MockTxnMockRecorder
- func (mr *MockTxnMockRecorder) BestEffort() *gomock.Call
- func (mr *MockTxnMockRecorder) Commit(ctx any) *gomock.Call
- func (mr *MockTxnMockRecorder) Discard(ctx any) *gomock.Call
- func (mr *MockTxnMockRecorder) Do(ctx, req any) *gomock.Call
- func (mr *MockTxnMockRecorder) Mutate(ctx, mu any) *gomock.Call
- func (mr *MockTxnMockRecorder) Query(ctx, q any) *gomock.Call
- func (mr *MockTxnMockRecorder) QueryRDF(ctx, q any) *gomock.Call
- func (mr *MockTxnMockRecorder) QueryRDFWithVars(ctx, q, vars any) *gomock.Call
- func (mr *MockTxnMockRecorder) QueryWithVars(ctx, q, vars any) *gomock.Call
- type Mutation
- type Operation
- type PrometheusMetrics
- type QueryLog
- type Txn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the Dgraph client with logging and metrics.
func (*Client) Connect ¶
func (d *Client) Connect()
Connect connects to the Dgraph database using the provided configuration.
func (*Client) HealthCheck ¶
HealthCheck performs a basic health check by pinging the Dgraph server.
func (*Client) Mutate ¶
Mutate executes a write operation (mutation) in the Dgraph database and returns the result.
func (*Client) NewReadOnlyTxn ¶
NewReadOnlyTxn creates a new read-only transaction for querying the Dgraph database.
func (*Client) NewTxn ¶
NewTxn creates a new transaction (read-write) for interacting with the Dgraph database.
func (*Client) Query ¶
Query executes a read-only query in the Dgraph database and returns the result.
func (*Client) QueryWithVars ¶
func (d *Client) QueryWithVars(ctx context.Context, query string, vars map[string]string) (any, error)
QueryWithVars executes a read-only query with variables in the Dgraph database. QueryWithVars executes a read-only query with variables in the Dgraph database.
func (*Client) UseLogger ¶
UseLogger sets the logger for the Dgraph client which asserts the Logger interface.
func (*Client) UseMetrics ¶
UseMetrics sets the metrics for the Dgraph client which asserts the Metrics interface.
type DgraphClient ¶
type DgraphClient interface { // NewTxn creates a new transaction (read-write) for interacting with the Dgraph database. NewTxn() Txn // NewReadOnlyTxn creates a new read-only transaction for querying the Dgraph database. NewReadOnlyTxn() Txn // Alter applies schema or other changes to the Dgraph database. Alter(ctx context.Context, op *api.Operation) error // Login logs in to the Dgraph database. Login(ctx context.Context, userid string, password string) error // LoginIntoNamespace logs in to the Dgraph database with a specific namespace. LoginIntoNamespace(ctx context.Context, userid string, password string, namespace uint64) error // GetJwt returns the JWT token for the Dgraph client. GetJwt() api.Jwt // Relogin relogs in to the Dgraph database. Relogin(ctx context.Context) error }
DgraphClient is an interface that defines the methods for interacting with Dgraph.
func NewDgraphClient ¶
func NewDgraphClient(client *dgo.Dgraph) DgraphClient
NewDgraphClient returns a new Dgraph client.
type Logger ¶
type Logger interface { Debug(args ...interface{}) Debugf(pattern string, args ...interface{}) Log(args ...interface{}) Logf(pattern string, args ...interface{}) Error(args ...interface{}) Errorf(pattern string, args ...interface{}) }
Logger interface with required methods.
type MockDgraphClient ¶
type MockDgraphClient struct {
// contains filtered or unexported fields
}
MockDgraphClient is a mock of DgraphClient interface.
func NewMockDgraphClient ¶
func NewMockDgraphClient(ctrl *gomock.Controller) *MockDgraphClient
NewMockDgraphClient creates a new mock instance.
func (*MockDgraphClient) EXPECT ¶
func (m *MockDgraphClient) EXPECT() *MockDgraphClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockDgraphClient) GetJwt ¶
func (m *MockDgraphClient) GetJwt() api.Jwt
GetJwt mocks base method.
func (*MockDgraphClient) Login ¶
func (m *MockDgraphClient) Login(ctx context.Context, userid, password string) error
Login mocks base method.
func (*MockDgraphClient) LoginIntoNamespace ¶
func (m *MockDgraphClient) LoginIntoNamespace(ctx context.Context, userid, password string, namespace uint64) error
LoginIntoNamespace mocks base method.
func (*MockDgraphClient) NewReadOnlyTxn ¶
func (m *MockDgraphClient) NewReadOnlyTxn() Txn
NewReadOnlyTxn mocks base method.
type MockDgraphClientMockRecorder ¶
type MockDgraphClientMockRecorder struct {
// contains filtered or unexported fields
}
MockDgraphClientMockRecorder is the mock recorder for MockDgraphClient.
func (*MockDgraphClientMockRecorder) Alter ¶
func (mr *MockDgraphClientMockRecorder) Alter(ctx, op any) *gomock.Call
Alter indicates an expected call of Alter.
func (*MockDgraphClientMockRecorder) GetJwt ¶
func (mr *MockDgraphClientMockRecorder) GetJwt() *gomock.Call
GetJwt indicates an expected call of GetJwt.
func (*MockDgraphClientMockRecorder) Login ¶
func (mr *MockDgraphClientMockRecorder) Login(ctx, userid, password any) *gomock.Call
Login indicates an expected call of Login.
func (*MockDgraphClientMockRecorder) LoginIntoNamespace ¶
func (mr *MockDgraphClientMockRecorder) LoginIntoNamespace(ctx, userid, password, namespace any) *gomock.Call
LoginIntoNamespace indicates an expected call of LoginIntoNamespace.
func (*MockDgraphClientMockRecorder) NewReadOnlyTxn ¶
func (mr *MockDgraphClientMockRecorder) NewReadOnlyTxn() *gomock.Call
NewReadOnlyTxn indicates an expected call of NewReadOnlyTxn.
func (*MockDgraphClientMockRecorder) NewTxn ¶
func (mr *MockDgraphClientMockRecorder) NewTxn() *gomock.Call
NewTxn indicates an expected call of NewTxn.
type MockLogger ¶
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger is a mock of Logger interface.
func NewMockLogger ¶
func NewMockLogger(ctrl *gomock.Controller) *MockLogger
NewMockLogger creates a new mock instance.
func (*MockLogger) Debugf ¶
func (m *MockLogger) Debugf(pattern string, args ...any)
Debugf mocks base method.
func (*MockLogger) EXPECT ¶
func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLogger) Errorf ¶
func (m *MockLogger) Errorf(pattern string, args ...any)
Errorf mocks base method.
func (*MockLogger) Logf ¶
func (m *MockLogger) Logf(pattern string, args ...any)
Logf mocks base method.
type MockLoggerMockRecorder ¶
type MockLoggerMockRecorder struct {
// contains filtered or unexported fields
}
MockLoggerMockRecorder is the mock recorder for MockLogger.
func (*MockLoggerMockRecorder) Debug ¶
func (mr *MockLoggerMockRecorder) Debug(args ...any) *gomock.Call
Debug indicates an expected call of Debug.
func (*MockLoggerMockRecorder) Debugf ¶
func (mr *MockLoggerMockRecorder) Debugf(pattern any, args ...any) *gomock.Call
Debugf indicates an expected call of Debugf.
func (*MockLoggerMockRecorder) Error ¶
func (mr *MockLoggerMockRecorder) Error(args ...any) *gomock.Call
Error indicates an expected call of Error.
func (*MockLoggerMockRecorder) Errorf ¶
func (mr *MockLoggerMockRecorder) Errorf(pattern any, args ...any) *gomock.Call
Errorf indicates an expected call of Errorf.
type MockMetrics ¶
type MockMetrics struct {
// contains filtered or unexported fields
}
MockMetrics is a mock of Metrics interface.
func NewMockMetrics ¶
func NewMockMetrics(ctrl *gomock.Controller) *MockMetrics
NewMockMetrics creates a new mock instance.
func (*MockMetrics) EXPECT ¶
func (m *MockMetrics) EXPECT() *MockMetricsMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockMetrics) NewHistogram ¶
func (m *MockMetrics) NewHistogram(name, desc string, buckets ...float64)
NewHistogram mocks base method.
func (*MockMetrics) RecordHistogram ¶
func (m *MockMetrics) RecordHistogram(ctx context.Context, name string, value float64, labels ...string)
RecordHistogram mocks base method.
type MockMetricsMockRecorder ¶
type MockMetricsMockRecorder struct {
// contains filtered or unexported fields
}
MockMetricsMockRecorder is the mock recorder for MockMetrics.
func (*MockMetricsMockRecorder) NewHistogram ¶
func (mr *MockMetricsMockRecorder) NewHistogram(name, desc any, buckets ...any) *gomock.Call
NewHistogram indicates an expected call of NewHistogram.
func (*MockMetricsMockRecorder) RecordHistogram ¶
func (mr *MockMetricsMockRecorder) RecordHistogram(ctx, name, value any, labels ...any) *gomock.Call
RecordHistogram indicates an expected call of RecordHistogram.
type MockTxn ¶
type MockTxn struct {
// contains filtered or unexported fields
}
MockTxn is a mock of Txn interface.
func NewMockTxn ¶
func NewMockTxn(ctrl *gomock.Controller) *MockTxn
NewMockTxn creates a new mock instance.
func (*MockTxn) EXPECT ¶
func (m *MockTxn) EXPECT() *MockTxnMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockTxnMockRecorder ¶
type MockTxnMockRecorder struct {
// contains filtered or unexported fields
}
MockTxnMockRecorder is the mock recorder for MockTxn.
func (*MockTxnMockRecorder) BestEffort ¶
func (mr *MockTxnMockRecorder) BestEffort() *gomock.Call
BestEffort indicates an expected call of BestEffort.
func (*MockTxnMockRecorder) Commit ¶
func (mr *MockTxnMockRecorder) Commit(ctx any) *gomock.Call
Commit indicates an expected call of Commit.
func (*MockTxnMockRecorder) Discard ¶
func (mr *MockTxnMockRecorder) Discard(ctx any) *gomock.Call
Discard indicates an expected call of Discard.
func (*MockTxnMockRecorder) Do ¶
func (mr *MockTxnMockRecorder) Do(ctx, req any) *gomock.Call
Do indicates an expected call of Do.
func (*MockTxnMockRecorder) Mutate ¶
func (mr *MockTxnMockRecorder) Mutate(ctx, mu any) *gomock.Call
Mutate indicates an expected call of Mutate.
func (*MockTxnMockRecorder) Query ¶
func (mr *MockTxnMockRecorder) Query(ctx, q any) *gomock.Call
Query indicates an expected call of Query.
func (*MockTxnMockRecorder) QueryRDF ¶
func (mr *MockTxnMockRecorder) QueryRDF(ctx, q any) *gomock.Call
QueryRDF indicates an expected call of QueryRDF.
func (*MockTxnMockRecorder) QueryRDFWithVars ¶
func (mr *MockTxnMockRecorder) QueryRDFWithVars(ctx, q, vars any) *gomock.Call
QueryRDFWithVars indicates an expected call of QueryRDFWithVars.
func (*MockTxnMockRecorder) QueryWithVars ¶
func (mr *MockTxnMockRecorder) QueryWithVars(ctx, q, vars any) *gomock.Call
QueryWithVars indicates an expected call of QueryWithVars.
type PrometheusMetrics ¶
type PrometheusMetrics struct {
// contains filtered or unexported fields
}
func (*PrometheusMetrics) NewHistogram ¶
func (p *PrometheusMetrics) NewHistogram(name, desc string, buckets ...float64)
NewHistogram creates a new histogram metric with the given name, description, and optional bucket sizes.
func (*PrometheusMetrics) RecordHistogram ¶
func (p *PrometheusMetrics) RecordHistogram(_ context.Context, name string, value float64, labels ...string)
RecordHistogram records a value to the specified histogram metric with optional labels.
type QueryLog ¶
type QueryLog struct { Type string `json:"type"` URL string `json:"url"` Duration int64 `json:"duration"` // Duration in microseconds }
QueryLog represents the structure for query logging.
func (*QueryLog) PrettyPrint ¶
PrettyPrint logs the QueryLog in a structured format to the given writer.
type Txn ¶
type Txn interface { // BestEffort sets the transaction to best-effort mode. BestEffort() Txn // Query executes a query against the transaction. Query(ctx context.Context, q string) (*api.Response, error) // QueryRDF executes an RDF query against the transaction. QueryRDF(ctx context.Context, q string) (*api.Response, error) // QueryWithVars executes a query with variables against the transaction. QueryWithVars(ctx context.Context, q string, vars map[string]string) (*api.Response, error) // QueryRDFWithVars executes an RDF query with variables against the transaction. QueryRDFWithVars(ctx context.Context, q string, vars map[string]string) (*api.Response, error) // Mutate applies a mutation to the transaction. Mutate(ctx context.Context, mu *api.Mutation) (*api.Response, error) // Do performs a raw request against the transaction. Do(ctx context.Context, req *api.Request) (*api.Response, error) // Commit commits the transaction. Commit(ctx context.Context) error // Discard discards the transaction. Discard(ctx context.Context) error }
Txn is an interface for Dgraph transactions.