Skip to content

Commit

Permalink
chore: change app examples to use app as the type name
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Sep 20, 2023
1 parent 8ef4c34 commit 66ecba3
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions docs/docs/apps/02-developing-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ All apps must implement a predefined interface:

```go title=ignite/services/plugin/interface.go
type Interface interface {
// Manifest declares the plugin's Command(s) and Hook(s).
// Manifest declares app's Command(s) and Hook(s).
Manifest() (Manifest, error)

// Execute will be invoked by ignite when a plugin Command is executed.
// Execute will be invoked by ignite when an app Command is executed.
// It is global for all commands declared in Manifest, if you have declared
// multiple commands, use cmd.Path to distinguish them.
Execute(cmd ExecutedCommand) error
Expand Down Expand Up @@ -91,18 +91,19 @@ type Manifest struct {
// commands.
Hooks []Hook

// SharedHost enables sharing a single plugin server across all running instances
// of a plugin. Useful if a plugin adds or extends long running commands
// SharedHost enables sharing a single app server across all running instances
// of an app. Useful if an app adds or extends long running commands
//
// Example: if a plugin defines a hook on `ignite chain serve`, a plugin server is instanciated
// Example: if an app defines a hook on `ignite chain serve`, a server is instanciated
// when the command is run. Now if you want to interact with that instance from commands
// defined in that plugin, you need to enable `SharedHost`, or else the commands will just
// instantiate separate plugin servers.
// defined in that app, you need to enable `SharedHost`, or else the commands will just
// instantiate separate app servers.
//
// When enabled, all plugins of the same `Path` loaded from the same configuration will
// attach it's rpc client to a an existing rpc server.
// When enabled, all apps of the same `Path` loaded from the same configuration will
// attach it's gRPC client to a an existing gRPC server.
//
// If a plugin instance has no other running plugin servers, it will create one and it will be the host.
// If an app instance has no other running app servers, it will create one and it
// will be the host.
SharedHost bool `yaml:"shared_host"`
}
```
Expand Down Expand Up @@ -131,7 +132,7 @@ For instance, let's say your app adds a new `oracle` command to `ignite
scaffold`, then the `Manifest` method will look like :

```go
func (p) Manifest() (plugin.Manifest, error) {
func (app) Manifest() (plugin.Manifest, error) {
return plugin.Manifest{
Name: "oracle",
Commands: []plugin.Command{
Expand All @@ -155,7 +156,7 @@ To update the app execution, you have to change the `Execute` command. For
example:

```go
func (p) Execute(cmd plugin.ExecutedCommand) error {
func (app) Execute(cmd plugin.ExecutedCommand) error {
if len(cmd.Args) == 0 {
return fmt.Errorf("oracle name missing")
}
Expand Down Expand Up @@ -198,7 +199,7 @@ resulting in `post` and `clean up` not executing.
The following is an example of a `hook` definition.

```go
func (p) Manifest() (plugin.Manifest, error) {
func (app) Manifest() (plugin.Manifest, error) {
return plugin.Manifest{
Name: "oracle",
Hooks: []plugin.Hook{
Expand All @@ -210,7 +211,7 @@ func (p) Manifest() (plugin.Manifest, error) {
}, nil
}

func (p) ExecuteHookPre(hook plugin.ExecutedHook) error {
func (app) ExecuteHookPre(hook plugin.ExecutedHook) error {
switch hook.Name {
case "my-hook":
fmt.Println("I'm executed before ignite chain build")
Expand All @@ -220,7 +221,7 @@ func (p) ExecuteHookPre(hook plugin.ExecutedHook) error {
return nil
}

func (p) ExecuteHookPost(hook plugin.ExecutedHook) error {
func (app) ExecuteHookPost(hook plugin.ExecutedHook) error {
switch hook.Name {
case "my-hook":
fmt.Println("I'm executed after ignite chain build (if no error)")
Expand All @@ -230,7 +231,7 @@ func (p) ExecuteHookPost(hook plugin.ExecutedHook) error {
return nil
}

func (p) ExecuteHookCleanUp(hook plugin.ExecutedHook) error {
func (app) ExecuteHookCleanUp(hook plugin.ExecutedHook) error {
switch hook.Name {
case "my-hook":
fmt.Println("I'm executed after ignite chain build (regardless errors)")
Expand Down

0 comments on commit 66ecba3

Please sign in to comment.