You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least need three services: generate mysql.sql, generate mysql.go, and generate volatile-memory.go files.
Input example:
// Storage_Fields indicates the domain record data fields.typeStorage_Fieldsinterface {
RequestID() UserRequestUUID//DomainID() uint64// Domain MediaTypeID e.g. product, content, ... domainServiceID() uint64//UserID() protocol.UserID// user domainUserConnectionID() [16]byte// Store to remember which request belongs to which Connection/AppInstance.Time() protocol.Time// Request time or save Time of the request not the created record by this record.
}
// Storage_Services indicates the domain storage layer services.typeStorage_Servicesinterface {
Save(sfStorage_Fields) (err protocol.Error)
Get(requestIDUserRequestUUID, vo protocol.VersionOffset) (sfStorage_Fields, err protocol.Error)
FindByDomain(domainIDuint64, offset, limituint64) (requestIDs []UserRequestUUID, err protocol.Error)
FindByUser(userID [16]byte, offset, limituint64) (requestIDs []UserRequestUUID, err protocol.Error)
}
Develop to easily add support for multiple storage engines (other than SQL based) in future
generate MySQL, Postgres, ... optimized SQL not general SQL codes
Use SQL procedure for queries not send a query in each request.
Problems need to fix in comparison to other modules:
As long as it is possible logic must be in compile-time not runtime.
Respect object life cycle and abstraction patterns. e.g. Initiliaze of each domain storage must take place in that domain, not the main of the application.
All existing modules in the Go ecosystem force the developer to write the storage layer handly! we need to write efficient codes for the storage layer by given storage interfaces.
It means we don't need these fancy things:
users, err:=models.Users(
Select("id", "name"),
InnerJoin("credit_cards c on c.user_id = users.id"),
Where("age > ?", 30),
AndIn("c.kind in ?", "visa", "mastercard"),
Or("email like ?", `%aol.com%`),
GroupBy("id", "name"),
Having("count(c.id) > ?", 2),
Limit(5),
Offset(6),
).All(ctx, db)
sqlc is the opposite of our way! the sqlc forces developers to write SQL files, but we force them to write some interfaces to generate both SQL and storage layer logic.
Hints:
mysql.sql
, generatemysql.go
, and generatevolatile-memory.go
files.Problems need to fix in comparison to other modules:
It means we don't need these fancy things:
other modules:
The text was updated successfully, but these errors were encountered: