Skip to content

Commit

Permalink
refactor: modify annotation name (openGemini#100)
Browse files Browse the repository at this point in the history
Signed-off-by: weiping-code <[email protected]>
  • Loading branch information
weiping-code authored Aug 25, 2024
1 parent 5cdb384 commit e4ece2e
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.context.annotation.Bean;
import reactor.core.publisher.Flux;

@AutoConfiguration(after = OpenGeminiAutoConfiguration.class)
@AutoConfiguration
@ConditionalOnClass({ReactiveOpenGeminiTemplate.class, Flux.class})
public class OpenGeminiReactiveAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package io.opengemini.client.spring.data.config;

import io.opengemini.client.spring.data.TestReactiveApplication;
import io.opengemini.client.spring.data.core.OpenGeminiProperties;
import io.opengemini.client.spring.data.core.OpenGeminiTemplate;
import io.opengemini.client.spring.data.core.ReactiveOpenGeminiTemplate;
import io.opengemini.client.spring.data.sample.TestReactiveApplication;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -17,9 +16,6 @@ public class OpenGeminiReactiveAutoConfigurationTest {
@Autowired
private OpenGeminiProperties openGeminiProperties;

@Autowired
private OpenGeminiTemplate openGeminiTemplate;

@Autowired
private ReactiveOpenGeminiTemplate reactiveOpenGeminiTemplate;

Expand All @@ -29,11 +25,6 @@ public void properties_bean_should_be_declared() {
Assertions.assertEquals("localhost:8086", openGeminiProperties.getAddresses().get(0));
}

@Test
public void template_bean_should_be_declared() {
Assertions.assertNotNull(openGeminiTemplate);
}

@Test
public void reactive_template_bean_should_be_declared() {
Assertions.assertNotNull(reactiveOpenGeminiTemplate);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.opengemini.client.spring.data;
package io.opengemini.client.spring.data.sample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.opengemini.client.spring.data.config;

import io.opengemini.client.spring.data.TestApplication;
import io.opengemini.client.spring.data.core.OpenGeminiProperties;
import io.opengemini.client.spring.data.core.OpenGeminiTemplate;
import io.opengemini.client.spring.data.sample.TestApplication;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.opengemini.client.spring.data;
package io.opengemini.client.spring.data.sample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.opengemini.client.spring.data.sample.measurement;


import io.opengemini.client.api.Precision;
import io.opengemini.client.spring.data.annotation.Database;
import io.opengemini.client.spring.data.annotation.Field;
import io.opengemini.client.spring.data.annotation.Measurement;
import io.opengemini.client.spring.data.annotation.RetentionPolicy;
import io.opengemini.client.spring.data.annotation.Tag;
import io.opengemini.client.spring.data.annotation.Time;
import lombok.Getter;
import lombok.Setter;

@Database(name = "testdb", create = false)
@RetentionPolicy(name = "testrp", create = false)
@Measurement(name = "testms")
@Getter
@Setter
public class WeatherFixNameNoCreate {

@Tag(name = "Location")
private String location;

@Field(name = "Temperature")
private Double temperature;

@Time(precision = Precision.PRECISIONMILLISECOND)
private Long time;

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.opengemini.client.spring.data.annotations;
package io.opengemini.client.spring.data.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* If unannotated, the method in OpenGeminiTemplate that requires a database name should be used.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Database {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.opengemini.client.spring.data.annotations;
package io.opengemini.client.spring.data.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -7,13 +7,11 @@

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Column {
public @interface Field {

/**
* If unset, the annotated field's name will be used as the column name.
* If unset, the annotated field's name will be used as the field name.
*/
String name();

boolean tag() default false;

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.opengemini.client.spring.data.annotations;
package io.opengemini.client.spring.data.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -9,6 +9,9 @@
@Target(ElementType.TYPE)
public @interface Measurement {

String name();
/**
* If unset, the method in OpenGeminiTemplate that requires a measurement name should be used.
*/
String name() default "";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.opengemini.client.spring.data.annotation;

import org.springframework.core.annotation.AliasFor;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface MeasurementScan {

/**
* Alias for {@link #basePackages}.
* <p>Allows for more concise annotation declarations if no other attributes
* are needed &mdash; for example, {@code @MeasurementScan("org.my.pkg")}
* instead of {@code @MeasurementScan(basePackages = "org.my.pkg")}.
*/
@AliasFor("basePackages")
String[] value() default {};

/**
* Base packages to scan for annotated measurements.
* <p>{@link #value} is an alias for this attribute.
*/
@AliasFor("value")
String[] basePackages() default {};

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.opengemini.client.spring.data.annotations;
package io.opengemini.client.spring.data.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* If unannotated, the method in OpenGeminiTemplate that requires a retention policy name should be used.
*/
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface RetentionPolicy {
Expand All @@ -12,9 +15,9 @@

boolean create() default true;

String duration();
String duration() default "";

String shardGroupDuration();
String shardGroupDuration() default "";

String hotDuration() default "";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.opengemini.client.spring.data.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Tag {

/**
* If unset, the annotated field's name will be used as the tag name.
*/
String name();

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.opengemini.client.spring.data.annotations;
package io.opengemini.client.spring.data.annotation;

import io.opengemini.client.api.Precision;

Expand All @@ -9,7 +9,7 @@

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface TimeColumn {
public @interface Time {

Precision precision() default Precision.PRECISIONMILLISECOND;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package io.opengemini.client.spring.data.annotation;

This file was deleted.

0 comments on commit e4ece2e

Please sign in to comment.