Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var TemplateFiles = map[string][]fileNode{
"Basic": {
{
Name: "blixt.pkl",
Content: `amends "https://lib.blxt.org/pkl/base.pkl"
import "https://lib.blxt.org/pkl/blixt.pkl"
import "https://lib.blxt.org/pkl/stdlib.pkl"
go_module = "{project}"
// all blocks that are used in the project are included here
blocks = new {
stdlib.echo
}`,
NextSteps: ` 1. cd {project}
2. blixt dev
`,
},
},
"Basic Custom": {
{
Name: "blixt.pkl",
Content: `amends "https://lib.blxt.org/pkl/base.pkl"
import "https://lib.blxt.org/pkl/blixt.pkl"
import "https://lib.blxt.org/pkl/stdlib.pkl"
go_module = "{project}"
// all blocks that are used in the project are included here
blocks = new {
my_block
}
// define a custom block
my_block = (blixt.block) {
name = "my_block",
// replace this with the go package name
package = "{project}/blocks/my_block",
remote = false
// these are the methods that the block will expose
methods = (blixt.methods) {
(blixt.method) {
name = "do_something",
request = new {
//any grpc type here
["some_param"] = "string"
}
response = new {
["some_response"] = "string"
}
}
}
}
`,
NextSteps: ` 1. cd {project}
2. Implement your block in blocks/my_block/block.go
3. blixt dev
`,
},
{
Name: "block.go",
Content: `//implement your block here
package my_block
import (
"context"
"log"
"{project}/gen/my_block"
apiv1 "{project}/gen/proto/v1"
)
type state struct {
// add any state here
// also store connections to other blocks here
// e.g. someBlock some_block.Block
}
func New() (my_block.Block, error) {
// initialize any persistent state here
return &state{}, nil
}
func (s *state) DoSomething(
ctx context.Context,
req *apiv1.MyBlockDoSomethingRequest,
)(*apiv1.MyBlockDoSomethingResponse, error) {
log.Printf("Doing something with %s", req.SomeParam)
return &apiv1.MyBlockDoSomethingResponse{
SomeResponse: "some response",
}, nil
}
func (s *state) Name() string {
return my_block.Name
}
func (s *state) Connect(ctx context.Context, block string, conn interface{}) error {
// generally, switch on the block name, and store the block in the state
// you can then call methods on the block
// which will be forwarded over the network if the block is in
// a different group
/*
switch block {
case "some_block":
s.someBlock = (conn).(some_block.Block)
}
*/
return nil
}
`,
Parent: "blocks/my_block",
},
},
"User Management": {
{
Name: "blixt.pkl",
Content: `amends "https://lib.blxt.org/pkl/base.pkl"
import "https://lib.blxt.org/pkl/blixt.pkl"
import "https://lib.blxt.org/pkl/stdlib.pkl"
go_module = "{project}"
blocks = new {
stdlib.auth
stdlib.db
stdlib.user
}
`,
NextSteps: ` 1. cd {project}
2. blixt dev`,
},
},
"Microservices": {
{
Name: "blixt.pkl",
Content: `amends "https://lib.blxt.org/pkl/base.pkl"
import "https://lib.blxt.org/pkl/blixt.pkl"
import "https://lib.blxt.org/pkl/stdlib.pkl"
go_module = "{project}"
// same basic blocks as the user management template
blocks = new {
stdlib.auth
stdlib.db
stdlib.user
}
// split the blocks over two microservices
groups = new {
(blixt.group) {
name = "auth_service",
blocks = new {stdlib.auth.name}
}
(blixt.group) {
name = "user_service",
blocks = new {
stdlib.db.name
stdlib.user.name
}
}
}
`,
NextSteps: ` 1. cd {project}
2. blixt dev`,
},
},
}
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.