🚀
Semaphore
  • Introduction
  • Getting started
    • Go API
    • CLI
    • Docker
    • Examples
  • Cookbook
    • Flows
      • References
      • Error handling
      • Conditional logic
      • Proxy forward
    • Schemas
      • Protobuffers
    • Transport
      • HTTP
      • Go micro
      • GraphQL
    • DevOps
  • Contributing
Powered by GitBook
On this page
  1. Getting started

Go API

Use one of the standard implementations or create one yourself.

PreviousGetting startedNextCLI

Last updated 4 years ago

Introduction

Semaphore exposes most of the internally used methods. This allows developers to create their own custom implementations. Please check out the .

$ go get github.com/jexia/maestro
package main

import (
	"github.com/jexia/maestro"
	"github.com/jexia/maestro/codec/json"
	"github.com/jexia/maestro/codec/proto"
	"github.com/jexia/maestro/definitions/hcl"
	"github.com/jexia/maestro/protocol/graphql"
	"github.com/jexia/maestro/protocol/http"
	"github.com/jexia/maestro/schema/protoc"
	"github.com/jexia/maestro/specs"
)

func main() {
    protobuffers, err := protoc.Collect([]string{"./"}, "./*")
    if err != nil {
        // handle err
    }

    client, err := maestro.New(
        maestro.WithListener(graphql.NewListener(":9090", specs.Options{})),
        maestro.WithListener(http.NewListener(":8080", specs.Options{})),
        maestro.WithDefinitions(hcl.DefinitionResolver("./*")),
        maestro.WithSchema(protobuffers),
        maestro.WithCodec(json.NewConstructor()),
        maestro.WithCodec(proto.NewConstructor()),
        maestro.WithCaller(http.NewCaller()),
    )
    
    if err != nil {
        // handle err
    }
    
    err = client.Serve()
    if err != nil {
        // handle err
    }
}

go docs