Skip to content

Commit 2aee44d

Browse files
fleandreiCopilot
andauthored
station plugin tuto updated to use plugin-kit go module rather than the hello-world plugin pkg code (#454)
* station plugin tuto updated to use plugin-kit go module rather than the hello-world plugin pkg code * Update docs/massaStation/hello-world-plugin.mdx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5334a34 commit 2aee44d

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

docs/massaStation/guidelines.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Currently, Massa Station supports the following OS configurations:
5050

5151
A plugin Zip Archive must contain the following files and adhere to the specified structure:
5252

53-
1. **Plugin Binary**: The plugin's binary, withch should follow the standards
53+
1. **Plugin Binary**: The plugin's binary, which should follow the standards
5454
2. **Logo**: The archive must include a valid image file that serves as the plugin's logo. Refer to [the Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types) for valid image formats.
5555
:::tip
5656
This logo will be displayed in the Massa Station interface. To ensure a good user experience, we recommend using a square image with a minimum size of 128x128 pixels.

docs/massaStation/hello-world-plugin.mdx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,20 @@ At this stage, we are running the API in standalone mode. In the next section, w
274274

275275
## Register to Massa Station
276276

277-
### Install the Massa Station Plugin package
277+
### Install the Massa Station plugin-kit module
278278

279-
To be able to register the plugin with Massa Station, we need to install the Massa Station Plugin package. Indeed, this package contains the `RegisterPlugin` function that allows us to register the plugin to Massa Station.
279+
To be able to register the plugin with Massa Station, we need to install the [plugin-kit](https://github.com/massalabs/station/tree/main/plugin-kit) go module.
280+
The plugin-kit module provides useful features to develop Massa Station plugins in golang.
281+
Here, we are going to use the `RegisterPlugin` function that allows us to register the plugin to Massa Station.
280282

281283
Install the following package:
282284
```bash
283-
go get github.com/massalabs/station-massa-hello-world
285+
go get github.com/massalabs/station/plugin-kit
284286
```
285287

286288
This package will be imported to `my-plugin.go` file. So go ahead and add the following line to the imports section of `my-plugin.go`:
287289
```go
288-
"github.com/massalabs/station-massa-hello-world/pkg/plugin"
290+
"github.com/massalabs/station/plugin-kit"
289291
```
290292
The import section of your `my-plugin.go` file should look like this:
291293

@@ -304,7 +306,7 @@ import (
304306
"github.com/go-openapi/loads"
305307
"github.com/rs/cors"
306308
307-
"github.com/massalabs/station-massa-hello-world/pkg/plugin"
309+
pluginKit "github.com/massalabs/station/plugin-kit"
308310
)
309311
```
310312
Once this is done, we will add the registration logic to our main function. We want to add the following lines to the main function:
@@ -315,7 +317,7 @@ Once this is done, we will add the registration logic to our main function. We w
315317
panic(err)
316318
}
317319
318-
plugin.RegisterPlugin(listener) // registers the plugin
320+
pluginKit.RegisterPlugin(listener) // registers the plugin
319321
```
320322
They should be added right after the `server := initializeAPI()` line. In the end, your main function should look like this:
321323

@@ -334,7 +336,10 @@ func main() {
334336
panic(err)
335337
}
336338
337-
plugin.RegisterPlugin(listener) // registers the plugin
339+
err = pluginKit.RegisterPlugin(listener) // registers the plugin
340+
if err != nil {
341+
panic(err)
342+
}
338343
339344
if err := server.Serve(); err != nil {
340345
panic(err)
@@ -346,7 +351,7 @@ func main() {
346351
```
347352

348353
:::info
349-
`plugin.RegisterPlugin` is a function available in the [hello-world plugin package](https://github.com/massalabs/station-massa-hello-world/blob/main/pkg/plugin/register.go).
354+
`pluginKit.RegisterPlugin` is a function available in the [plugin-kit module](https://github.com/massalabs/station/blob/main/plugin-kit/register.go).
350355

351356
It facilitates the registration of a plugin with Massa Station, assigning a unique correlation ID to the plugin for identification purposes within the Massa Station system.
352357
:::
@@ -740,7 +745,7 @@ import (
740745
"github.com/go-openapi/loads"
741746
"github.com/rs/cors"
742747
743-
"github.com/massalabs/station-massa-hello-world/pkg/plugin"
748+
pluginKit "github.com/massalabs/station/plugin-kit"
744749
)
745750
```
746751

0 commit comments

Comments
 (0)