Documentation
¶
Overview ¶
Package storage defines pluggable persistence and routing abstractions. All interfaces ship with in-memory defaults in core/storage/memory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotLocal = errors.New("storage: charge point not local")
ErrNotLocal indicates the target charge point is not connected to this instance.
var ErrRouterNotImplemented = errors.New("storage: remote routing not implemented")
ErrRouterNotImplemented indicates remote routing is unsupported (single-instance).
Functions ¶
This section is empty.
Types ¶
type ConfigStore ¶
type ConfigStore interface {
Put(ctx context.Context, cpID, key, value string) error
Get(ctx context.Context, cpID, key string) (string, bool, error)
List(ctx context.Context, cpID string) (map[string]string, error)
Delete(ctx context.Context, cpID, key string) error
}
ConfigStore persists charge point configuration key/value pairs. The library does not interpret values; it only stores what ChangeConfiguration/SetVariables produce.
type ConnectionRegistry ¶
type ConnectionRegistry interface {
PutLocal(ctx context.Context, cpID string, conn LiveConn) error
GetLocal(cpID string) (LiveConn, bool)
DeleteLocal(ctx context.Context, cpID string) error
RangeLocal(fn func(cpID string, conn LiveConn) bool)
PutGlobal(ctx context.Context, cpID, instanceID string) error
LookupGlobal(ctx context.Context, cpID string) (instanceID string, ok bool, err error)
DeleteGlobal(ctx context.Context, cpID string) error
}
ConnectionRegistry tracks which charge points are connected and (optionally) on which instance in a multi-instance deployment.
type LiveConn ¶
LiveConn is the minimal view of a live connection the registry needs. The dispatcher's *Conn satisfies this, avoiding an import cycle.
type MessageRouter ¶
type MessageRouter interface {
CallLocal(ctx context.Context, cpID, action string, req []byte) ([]byte, error)
CallRemote(ctx context.Context, cpID, action string, req []byte) ([]byte, error)
ServeRemote(ctx context.Context, handler RemoteHandler) error
}
MessageRouter forwards calls between CSMS instances. Single-instance deployments use a no-op router whose CallRemote returns ErrRouterNotImplemented.
type RemoteHandler ¶
RemoteHandler serves a forwarded call on the instance that holds the connection.
type Transaction ¶
type Transaction struct {
ID string
CPID string
EVSEID int
IDTag string
StartedAt time.Time
EndedAt *time.Time
MeterStart int
MeterStop *int
Status TransactionStatus
Metadata map[string]any
}
Transaction is a charging session record.
type TransactionEnd ¶
type TransactionEnd struct {
EndedAt time.Time
MeterStop int
Status TransactionStatus
}
TransactionEnd finalizes a session.
type TransactionMutation ¶
type TransactionMutation struct {
MeterValue *int
Status *TransactionStatus
Metadata map[string]any
}
TransactionMutation is a partial update applied during a session.
type TransactionStatus ¶
type TransactionStatus string
TransactionStatus is the lifecycle state of a charging transaction.
const ( TransactionActive TransactionStatus = "Active" TransactionCompleted TransactionStatus = "Completed" TransactionAborted TransactionStatus = "Aborted" )
type TransactionStore ¶
type TransactionStore interface {
Begin(ctx context.Context, tx Transaction) error
Update(ctx context.Context, txID string, mut TransactionMutation) error
End(ctx context.Context, txID string, end TransactionEnd) error
Get(ctx context.Context, txID string) (Transaction, error)
ListActive(ctx context.Context, cpID string) ([]Transaction, error)
}
TransactionStore persists charging transactions. The transaction ID is supplied by the caller (CP or CSMS depending on OCPP version), not generated by the store.