x

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 0 Imported by: 13

README

x Extension golang module placeholder

Motivation

This project serves as an extension placeholder for a Go module, facilitating an initial setup before dynamic loading of extensions via the Go plugin system.

Consider a scenario where a main application requires extension through custom Go types, which are dynamically reloadable. Suppose the extension module is hosted at github.com/myorg/myapp/extension. This module defines several types and registers them with the Type Registry

The main application, located at github.com/myorg/myapp, needs to access these types both through the Go plugin system for runtime extension and directly as a dependency for compile-time integration. This project is designed to support the direct dependency mechanism, ensuring seamless access to the extension types within the main application's ecosystem.

[Main Application] -> [Transient Extension Module] -> [Extension Module (github.com/myorg/myapp/extension)]

Main Application

The main application go mod.

module github.com/myorg/myapp

go 1.21
  require (
    github.com/viant/x v0.1.0
    github.com/viant/x/extension v0.1.0
    github.com/viant/pgo v0.11.0
    ...
  )
    
replace github.com/viant/x => ../../myorg/myapp/x
Transinet Extension Module

The local transient extension go.mod

module github.com/viant/x

go 1.21

require github.com/myorg/myapp/extension

The local transient extension init.go

import _ "github.com/myorg/myapp/extension"
Custom Extension Module

The local transient extension go.mod

module github.com/myorg/myapp/extension

go 1.21

require ...
Extension Module

The extension module registry.go

package mypkg

import (
    "github.com/viant/x/extension"
)


var registry = extension.NewRegistry(extension.WithListener(func(t *extension.Type) {
    // do something with the type
}))

//Register registers a type with options
func Register(t *extension.Type) {
    registry.Register(t)
}

//Registry returns extension registry
func Registry() *extension.Registry {
    return registry
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
extension module
transient module

Jump to

Keyboard shortcuts

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