fxslack

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 5 Imported by: 0

README

Fx Slack Module

ci go report codecov Deps PkgGoDev

Fx module for Slack.

Overview

This module provides to your Fx application a slack.Client, that you can inject anywhere to interact with the Slack API.

Installation

This module requires fxhttpclient.

Install the modules:

go get github.com/ankorstore/yokai/fxhttpclient
go get github.com/ankorstore/yokai-contrib/fxslack

Then activate them in your application bootstrapper:

// internal/bootstrap.go
package internal

import (
	"github.com/ankorstore/yokai-contrib/fxslack"
	"github.com/ankorstore/yokai/fxcore"
	"github.com/ankorstore/yokai/fxhttpclient"
)

var Bootstrapper = fxcore.NewBootstrapper().WithOptions(
	// load modules
	fxhttpclient.FxHttpClientModule,
	fxslack.FxSlackModule,
	// ...
)

Configuration

Configuration reference:

# ./configs/config.yaml
app:
  name: app
  env: dev
  version: 0.1.0
  debug: true
modules:
  slack:
    auth_token: ${SLACK_AUTH_TOKEN}  # Slack Auth Token
    app_level_token: ${SLACK_APP_LEVEL_TOKEN} # Slack App level Token

Testing

In test mode, this client is configured to interact with a fake slack server.

See example.

Documentation

Index

Constants

View Source
const ModuleName = "slack"

ModuleName is the module name.

Variables

FxSlack is the Fx slack module.

Functions

func NewSlackClient

func NewSlackClient(p FxSlackClientParam) *slack.Client

NewSlackClient returns a slack.Client.

func NewSlackTestServer

func NewSlackTestServer(p FxSlackTestServerParam) *slacktest.Server

NewSlackTestServer returns a slacktest.Server.

Types

type FxSlackClientParam

type FxSlackClientParam struct {
	fx.In
	LifeCycle        fx.Lifecycle
	HttpRoundTripper http.RoundTripper
	Config           *config.Config
	TestServer       *slacktest.Server
}

FxSlackClientParam allows injection of the required dependencies in NewSlackClient.

type FxSlackTestServerParam

type FxSlackTestServerParam struct {
	fx.In
	LifeCycle fx.Lifecycle
	Config    *config.Config
}

FxSlackTestServerParam allows injection of the required dependencies in NewSlackTestServer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL