Skip to content

kusanagi/kusanagi-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go SDK for the KUSANAGI framework

Go Report Card License: MIT

Go SDK to interface with the KUSANAGI™ framework (http://kusanagi.io).

Requirements

Installation

Install the SDK using the following command:

$ go get github.com/kusanagi/kusanagi-sdk-go/v5@epoch-5

Getting Started

See the getting started tutorial to begin with the KUSANAGI™ framework and the Go SDK.

Cancellation Signal

The Go SDK implements support to signal deadlines or cancellation through a read only channel that is available to Middleware and Service components.

The channel can be read using the Api.Done() method. For example, within a service action:

func handler(action *kusanagi.Action) (*kusanagi.Action, error) {
    // Create a context for the current service call
    ctx, cancel := context.WithCancel(context.Background())

    // Create a channel to get the task result
    result := make(chan int)

    // Run some async task
    go task(ctx, result)

    // Cancel the context when the service call times out
    select{
    case v := <-result:
       action.Log(v, 6)
    case <-action.Done():
        cancel()
    }

    return action, nil
}

It is highly recommended to monitor this channel and stop any ongoing task when the channel is closed.

Documentation

See the API for a technical reference of the SDK.

For help using the framework see the documentation.

Support

Please first read our contribution guidelines.

We use milestones to track upcoming releases inline with our versioning strategy, and as defined in our roadmap.

Contributing

If you'd like to know how you can help and support our Open Source efforts see the many ways to get involved.

Please also be sure to review our community guidelines.

License

Copyright 2016-2023 KUSANAGI S.L. (http://kusanagi.io). All rights reserved.

KUSANAGI, the sword logo and the "K" logo are trademarks and/or registered trademarks of KUSANAGI S.L. All other trademarks are property of their respective owners.

Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.