Skip to content

Go Project layout #7067

@igor-sirotin

Description

@igor-sirotin

Description

Repository structure must follow https://github.com/golang-standards/project-layout.

This will greatly improve the project readability and developer experience.
Also, getting the project into the proper structure will actually hlpe

Note: This is not just about putting files into certain directories. This should be meaningful, i.e.:

  • unused packages must be dorpped
  • some packages should be split into smaller domain-specific ones
  • packages with unknown purpose must not exist (e.g. "common")

Details

Some live-recorded details from offline discussion. Should be split into sub-issues.

  1. Cleanup accounts-management, perhaps rename to accounts
  2. api
    • Remove "signing phrase" (make sure it does not exist as a feature anymore
    • Remove StatusBacked interface
    • Rename GethStatusBackend -> StatusBackend
    • Goes to pkg
    • app_state -> change to non-app-related method/args (low power mode, low data mode)
    • StatusBackend moved to pkg/backend
    • create_account_and_login - either goes with backend or to users/app service
    • default_networks - should go to networks package (might touch settings)
    • Settings should be split into service-specific settings. A group of settings struct might make sense to exist
    • NodeConfig dies
    • multiformat -> pkg/multiformat
  3. Databases
    • appdatabase -> internal/db/appdatabase
    • walletdatabase >-> internal/db/walletdb should split into "migrations" and "creating db file"
    • multiaacounts -> internal/db/multiaacounts
      • this needs to be cleaned up A LOT
    • sqlite -> internal/db
  4. cetralizedmetrics -> services/cetralizedmetrics
  5. circuitbreaker -> intermal, then probably AFUERA!
  6. cmd
    • cmd/generate_handlers -> protocol/internal
    • cmd/library keep here, depends on how many c-bindings we have
  7. common/dbsetup -> internal/db
  8. common/device.go -> mostly should not exist, rest goes to internal/platform
  9. internal/connection (or LowDataMode)
  10. constants - split
  11. internal/contracts
  12. crypto - AFUERA (but internal for now)
  13. deprecation should most probably die (just in case check how timeline/profile chats were implemented)
  14. errors -> internal. Only use on API client-surfacing level.
  15. eth-node AFUERA
  16. healthmanager -> internal
  17. images -> internal
  18. ipfs -> internal
    • disabled in privacy mode
    • use own IPFS node instead
  19. logutils -> internal
  20. messaging -> internal
  21. mobile ->
    • separate into services
    • maybe name the API
    • some free functions might stay, or even be extracted in a separate library
  22. node -> pkg/backend
  23. params/networkhelper -> services/networks (where we instantiate RPCClient)
  24. cluster
    • remove waku settings from UI
    • Most probably AFUERA. Split into services configurations. First make sure it's not sued externally by clients.
  25. protocol move to internal
  26. rpc -> internal
  27. localpairing -> service
  28. server_media -> services/media
  29. services -> pkg
  30. signals -> internal
    • send signals not with global functions
    • status backend convert from services pubsub to signals
  31. static -> split into certain places
    • use go:embed instead of bindata
  32. t -> internal
  33. tests-functional and test-unit-network -> /test
  34. transactions -> internal and then afuera.
    PrivateKey should always be provided with MessageSigner inrerface

Service settings / NodeConfig

  • each service have its own settings, with persistence interface (most probably own table and migrations)
  • service have get/set methods for each setting. These would change the runtime and persisted values
  • during onboarding, user might define certain settings. Such should persist. So:
    usersService —setSmthEnabled--> newsfeedService --> Persistence
  • if a setting have to be overridden in runtime, it should be passed with go Option to service.Start()

We didn't agree on the approach yet. 2 options considered:

  • <Service>Config + Set<Setting>
  • type Settings interface with Get<Setting> <type> or GetSetting <-chan <type>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions