Documentation ¶
Overview ¶
Example (Flags) ¶
package main import ( "context" "flag" "fmt" "moul.io/u" "berty.tech/berty/v2/go/internal/initutil" ) func main() { // init manager ctx := context.Background() manager, err := initutil.New(ctx) if err != nil { panic(err) } defer manager.Close() // configure flags fmt.Println("before", u.JSON(manager.Node.GRPC)) fs := flag.NewFlagSet("test", flag.ExitOnError) manager.SetupLocalProtocolServerFlags(fs) manager.SetupRemoteNodeFlags(fs) manager.SetupDefaultGRPCListenersFlags(fs) err = fs.Parse([]string{"-store.inmem", "-p2p.min-backoff=2m10s", "-node.remote-addr=1.2.3.4:5678"}) if err != nil { panic(err) } fmt.Println("after ", u.JSON(manager.Node.GRPC)) }
Output: before {} after {"RemoteAddr":"1.2.3.4:5678","Listeners":"/ip4/127.0.0.1/tcp/9091/grpc"}
Example (Noflags) ¶
package main import ( "context" "flag" "fmt" "berty.tech/berty/v2/go/internal/initutil" "berty.tech/berty/v2/go/pkg/bertytypes" ) func main() { // init manager ctx := context.Background() manager, err := initutil.New(ctx) if err != nil { panic(err) } defer manager.Close() fs := flag.NewFlagSet("", flag.ExitOnError) manager.SetupLocalProtocolServerFlags(fs) manager.SetupRemoteNodeFlags(fs) fs.Parse([]string{}) // configure manager without flags manager.Node.GRPC.Listeners = "" manager.Node.Protocol.DisableIPFSNetwork = true manager.Datastore.InMemory = true // start a local berty protocol server _, err = manager.GetLocalProtocolServer() if err != nil { panic(err) } // build a client for the previously created protocol server client, err := manager.GetProtocolClient() if err != nil { panic(err) } // retrieve config ret, err := client.InstanceGetConfiguration(ctx, &bertytypes.InstanceGetConfiguration_Request{}) if err != nil { panic(err) } // check that the reply is valid (cannot check hardcoded value, since it's random) fmt.Println(ret.AccountPK != nil) }
Output: true
Index ¶
- Constants
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) DisableIPFSNetwork()
- func (m *Manager) GetContext() context.Context
- func (m *Manager) GetDatastoreDir() (string, error)
- func (m *Manager) GetGRPCClientConn() (*grpc.ClientConn, error)
- func (m *Manager) GetGRPCListeners() []grpcutil.Listener
- func (m *Manager) GetGRPCServer() (*grpc.Server, *grpcgw.ServeMux, error)
- func (m *Manager) GetLifecycleManager() *lifecycle.Manager
- func (m *Manager) GetLocalIPFS() (ipfsutil.ExtendedCoreAPI, *ipfs_core.IpfsNode, error)
- func (m *Manager) GetLocalMessengerServer() (bertymessenger.MessengerServiceServer, error)
- func (m *Manager) GetLocalProtocolServer() (bertyprotocol.Service, error)
- func (m *Manager) GetLogger() (*zap.Logger, error)
- func (m *Manager) GetMessengerClient() (bertymessenger.MessengerServiceClient, error)
- func (m *Manager) GetMessengerDB() (*gorm.DB, error)
- func (m *Manager) GetMetricsRegistry() (*prometheus.Registry, error)
- func (m *Manager) GetNotificationManager() (notification.Manager, error)
- func (m *Manager) GetOrbitDB() (*bertyprotocol.BertyOrbitDB, error)
- func (m *Manager) GetProtocolClient() (bertyprotocol.ProtocolServiceClient, error)
- func (m *Manager) GetRootDatastore() (datastore.Batching, error)
- func (m *Manager) RunWorkers() error
- func (m *Manager) SetLifecycleManager(manager *lifecycle.Manager)
- func (m *Manager) SetLogger(logger *zap.Logger)
- func (m *Manager) SetNotificationManager(manager notification.Manager)
- func (m *Manager) SetupDatastoreFlags(fs *flag.FlagSet)
- func (m *Manager) SetupDefaultGRPCListenersFlags(fs *flag.FlagSet)
- func (m *Manager) SetupEmptyGRPCListenersFlags(fs *flag.FlagSet)
- func (m *Manager) SetupLocalIPFSFlags(fs *flag.FlagSet)
- func (m *Manager) SetupLocalMessengerServerFlags(fs *flag.FlagSet)
- func (m *Manager) SetupLocalProtocolServerFlags(fs *flag.FlagSet)
- func (m *Manager) SetupLoggingFlags(fs *flag.FlagSet)
- func (m *Manager) SetupMetricsFlags(fs *flag.FlagSet)
- func (m *Manager) SetupNotificationManagerFlags(fs *flag.FlagSet)
- func (m *Manager) SetupProtocolAuth(fs *flag.FlagSet)
- func (m *Manager) SetupRemoteNodeFlags(fs *flag.FlagSet)
- type Preset
Examples ¶
Constants ¶
View Source
const InMemoryDir = ":memory:"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { Logging struct { Format string `json:"Format,omitempty"` Logfile string `json:"Logfile,omitempty"` Filters string `json:"Filters,omitempty"` Tracer string `json:"Tracer,omitempty"` Service string `json:"Service,omitempty"` // contains filtered or unexported fields } `json:"Logging,omitempty"` Metrics struct { Listener string `json:"Listener,omitempty"` Pedantic bool `json:"Pedantic,omitempty"` // contains filtered or unexported fields } `json:"Metrics,omitempty"` Datastore struct { Dir string `json:"Dir,omitempty"` InMemory bool `json:"InMemory,omitempty"` FileIO bool `json:"FileIO,omitempty"` // contains filtered or unexported fields } `json:"Datastore,omitempty"` Node struct { Preset Preset Protocol struct { IPFSListeners flagStringSlice `json:"IPFSListeners,omitempty"` IPFSAPIListeners flagStringSlice `json:"IPFSAPIListeners,omitempty"` IPFSWebUIListener string `json:"IPFSWebUIListener,omitempty"` Announce flagStringSlice `json:"Announce,omitempty"` NoAnnounce flagStringSlice `json:"NoAnnounce,omitempty"` LocalDiscovery bool `json:"LocalDiscovery,omitempty"` MultipeerConnectivity bool `json:"MultipeerConnectivity,omitempty"` MinBackoff time.Duration `json:"MinBackoff,omitempty"` MaxBackoff time.Duration `json:"MaxBackoff,omitempty"` DisableIPFSNetwork bool `json:"DisableIPFSNetwork,omitempty"` RdvpMaddrs flagStringSlice `json:"RdvpMaddrs,omitempty"` AuthSecret string `json:"AuthSecret,omitempty"` AuthPublicKey string `json:"AuthPublicKey,omitempty"` Tor struct { Enabled bool `json:"Enabled,omitempty"` BinaryPath string `json:"BinaryPath,omitempty"` } `json:"Tor,omitempty"` // contains filtered or unexported fields } Messenger struct { DisplayName string `json:"DisplayName,omitempty"` DisableNotifications bool `json:"DisableNotifications,omitempty"` RebuildSqlite bool `json:"RebuildSqlite,omitempty"` MessengerSqliteOpts string `json:"MessengerSqliteOpts,omitempty"` ExportPathToRestore string `json:"ExportPathToRestore,omitempty"` // contains filtered or unexported fields } GRPC struct { RemoteAddr string `json:"RemoteAddr,omitempty"` Listeners string `json:"Listeners,omitempty"` // contains filtered or unexported fields } `json:"GRPC,omitempty"` } `json:"Node,omitempty"` // contains filtered or unexported fields }
func (*Manager) DisableIPFSNetwork ¶
func (m *Manager) DisableIPFSNetwork()
func (*Manager) GetContext ¶
func (*Manager) GetDatastoreDir ¶
func (*Manager) GetGRPCClientConn ¶
func (m *Manager) GetGRPCClientConn() (*grpc.ClientConn, error)
func (*Manager) GetGRPCListeners ¶ added in v2.190.1
func (*Manager) GetGRPCServer ¶
func (*Manager) GetLifecycleManager ¶ added in v2.145.0
func (*Manager) GetLocalIPFS ¶ added in v2.141.0
func (*Manager) GetLocalMessengerServer ¶
func (m *Manager) GetLocalMessengerServer() (bertymessenger.MessengerServiceServer, error)
func (*Manager) GetLocalProtocolServer ¶
func (m *Manager) GetLocalProtocolServer() (bertyprotocol.Service, error)
func (*Manager) GetMessengerClient ¶
func (m *Manager) GetMessengerClient() (bertymessenger.MessengerServiceClient, error)
func (*Manager) GetMetricsRegistry ¶ added in v2.182.0
func (m *Manager) GetMetricsRegistry() (*prometheus.Registry, error)
func (*Manager) GetNotificationManager ¶ added in v2.190.1
func (m *Manager) GetNotificationManager() (notification.Manager, error)
func (*Manager) GetOrbitDB ¶ added in v2.141.0
func (m *Manager) GetOrbitDB() (*bertyprotocol.BertyOrbitDB, error)
func (*Manager) GetProtocolClient ¶
func (m *Manager) GetProtocolClient() (bertyprotocol.ProtocolServiceClient, error)
func (*Manager) RunWorkers ¶
func (*Manager) SetLifecycleManager ¶ added in v2.190.1
func (*Manager) SetNotificationManager ¶ added in v2.190.1
func (m *Manager) SetNotificationManager(manager notification.Manager)
func (*Manager) SetupDatastoreFlags ¶
func (*Manager) SetupDefaultGRPCListenersFlags ¶ added in v2.141.1
func (*Manager) SetupEmptyGRPCListenersFlags ¶ added in v2.141.1
func (*Manager) SetupLocalIPFSFlags ¶ added in v2.141.0
func (*Manager) SetupLocalMessengerServerFlags ¶
func (*Manager) SetupLocalProtocolServerFlags ¶
func (*Manager) SetupLoggingFlags ¶
func (*Manager) SetupMetricsFlags ¶ added in v2.182.0
func (*Manager) SetupNotificationManagerFlags ¶ added in v2.190.1
func (*Manager) SetupProtocolAuth ¶ added in v2.154.0
func (*Manager) SetupRemoteNodeFlags ¶
Click to show internal directories.
Click to hide internal directories.